From e64c0c693c47e4b3cf4b8067ab0951b9ca89284d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 19 Oct 2022 12:31:47 +0100 Subject: [PATCH 1/5] Add relative hidden directory tests --- codespell_lib/tests/test_basic.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index 8b73584a46..9da6a22e6a 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -383,6 +383,11 @@ def test_check_hidden(tmpdir, capsys): assert cs.main(d) == 0 assert cs.main('--check-hidden', d) == 2 assert cs.main('--check-hidden', '--check-filenames', d) == 5 + # check again with a relative path + rel = op.join('.', str(tmpdir)) + assert cs.main(rel) == 0 + assert cs.main('--check-hidden', rel) == 2 + assert cs.main('--check-hidden', '--check-filenames', rel) == 5 def test_case_handling(tmpdir, capsys): From aa7bcd74a1a1c4c6c938c286a191554c64b3644f Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 19 Oct 2022 12:51:05 +0100 Subject: [PATCH 2/5] Test a hidden subdirectory too --- codespell_lib/tests/test_basic.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index 9da6a22e6a..d21e26afaf 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -384,10 +384,22 @@ def test_check_hidden(tmpdir, capsys): assert cs.main('--check-hidden', d) == 2 assert cs.main('--check-hidden', '--check-filenames', d) == 5 # check again with a relative path - rel = op.join('.', str(tmpdir)) + rel = op.relpath(tmpdir) assert cs.main(rel) == 0 assert cs.main('--check-hidden', rel) == 2 assert cs.main('--check-hidden', '--check-filenames', rel) == 5 + # hidden subdirectory + assert cs.main(d) == 0 + assert cs.main('--check-hidden', d) == 2 + assert cs.main('--check-hidden', '--check-filenames', d) == 5 + subdir = op.join(d, 'subdir') + os.mkdir(subdir) + os.mkdir(op.join(subdir, '.abandonned')) + copyfile(op.join(d, '.abandonned.txt'), + op.join(subdir, '.abandonned', 'abandonned.txt')) + assert cs.main(d) == 0 + assert cs.main('--check-hidden', d) == 4 + assert cs.main('--check-hidden', '--check-filenames', d) == 10 def test_case_handling(tmpdir, capsys): From c54a29a5b84b6972902048bcf0eb7d64b314ba98 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 19 Oct 2022 13:00:00 +0100 Subject: [PATCH 3/5] Fix the expected typo numbers --- codespell_lib/tests/test_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index d21e26afaf..50245be814 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -398,8 +398,8 @@ def test_check_hidden(tmpdir, capsys): copyfile(op.join(d, '.abandonned.txt'), op.join(subdir, '.abandonned', 'abandonned.txt')) assert cs.main(d) == 0 - assert cs.main('--check-hidden', d) == 4 - assert cs.main('--check-hidden', '--check-filenames', d) == 10 + assert cs.main('--check-hidden', d) == 3 + assert cs.main('--check-hidden', '--check-filenames', d) == 7 def test_case_handling(tmpdir, capsys): From b39020c944ebbb67d4da89c6de84ff29658d7e63 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 19 Oct 2022 13:05:00 +0100 Subject: [PATCH 4/5] Recreate Dimitri's demo as a test --- codespell_lib/tests/test_basic.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index 50245be814..eecbc5dd92 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -399,7 +399,25 @@ def test_check_hidden(tmpdir, capsys): op.join(subdir, '.abandonned', 'abandonned.txt')) assert cs.main(d) == 0 assert cs.main('--check-hidden', d) == 3 - assert cs.main('--check-hidden', '--check-filenames', d) == 7 + assert cs.main('--check-hidden', '--check-filenames', d) == 8 + os.mkdir(op.join(d, '.abandonned', 'a')) + copyfile(op.join(d, '.abandonned.txt'), + op.join(d, '.abandonned', 'a', 'abandonned.txt')) + assert cs.main(d) == 0 + assert cs.main('--check-hidden', d) == 4 + assert cs.main('--check-hidden', '--check-filenames', d) == 11 + os.mkdir(op.join(d, '.abandonned', 'a', 'b')) + copyfile(op.join(d, '.abandonned.txt'), + op.join(d, '.abandonned', 'a', 'b', 'abandonned.txt')) + assert cs.main(d) == 0 + assert cs.main('--check-hidden', d) == 5 + assert cs.main('--check-hidden', '--check-filenames', d) == 14 + os.mkdir(op.join(d, '.abandonned', 'a', 'b', 'c')) + copyfile(op.join(d, '.abandonned.txt'), + op.join(d, '.abandonned', 'a', 'b', 'c', 'abandonned.txt')) + assert cs.main(d) == 0 + assert cs.main('--check-hidden', d) == 6 + assert cs.main('--check-hidden', '--check-filenames', d) == 17 def test_case_handling(tmpdir, capsys): From b34556c481e7c4f1aedfa94614f0cbe21eae2e03 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 19 Oct 2022 13:12:29 +0100 Subject: [PATCH 5/5] Remove the broken tests for now --- codespell_lib/tests/test_basic.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index eecbc5dd92..d7162607df 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -400,24 +400,6 @@ def test_check_hidden(tmpdir, capsys): assert cs.main(d) == 0 assert cs.main('--check-hidden', d) == 3 assert cs.main('--check-hidden', '--check-filenames', d) == 8 - os.mkdir(op.join(d, '.abandonned', 'a')) - copyfile(op.join(d, '.abandonned.txt'), - op.join(d, '.abandonned', 'a', 'abandonned.txt')) - assert cs.main(d) == 0 - assert cs.main('--check-hidden', d) == 4 - assert cs.main('--check-hidden', '--check-filenames', d) == 11 - os.mkdir(op.join(d, '.abandonned', 'a', 'b')) - copyfile(op.join(d, '.abandonned.txt'), - op.join(d, '.abandonned', 'a', 'b', 'abandonned.txt')) - assert cs.main(d) == 0 - assert cs.main('--check-hidden', d) == 5 - assert cs.main('--check-hidden', '--check-filenames', d) == 14 - os.mkdir(op.join(d, '.abandonned', 'a', 'b', 'c')) - copyfile(op.join(d, '.abandonned.txt'), - op.join(d, '.abandonned', 'a', 'b', 'c', 'abandonned.txt')) - assert cs.main(d) == 0 - assert cs.main('--check-hidden', d) == 6 - assert cs.main('--check-hidden', '--check-filenames', d) == 17 def test_case_handling(tmpdir, capsys):