From: Colin Watson Date: Tue, 30 Dec 2025 18:26:20 +0000 Subject: Tolerate missing example files in tests We strip tests/examplefiles from the source for licensing reasons. Last-Update: 2025-12-30 --- tests/test_basic_api.py | 5 ----- tests/test_guess.py | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index ad9eeac..51e3e31 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -58,11 +58,6 @@ def test_lexer_classes(cls): (f"Lexer class {cls.__name__} has a wrong version_added attribute. " "It should be a version number like . (but not " "..).") - if cls._example is not None: - assert isinstance(cls._example, str) - p = pathlib.Path(path.join(TESTDIR, "examplefiles", cls._example)) - assert p.is_file(), f"Example file {p} not found" - assert p.parent.name in cls.aliases, f"Example file {p} not in alias directory" result = cls.analyse_text("abc") assert isinstance(result, float) and 0.0 <= result <= 1.0 result = cls.analyse_text(".abc") diff --git a/tests/test_guess.py b/tests/test_guess.py index fe1a2f8..4de0137 100644 --- a/tests/test_guess.py +++ b/tests/test_guess.py @@ -207,6 +207,8 @@ def test_ecl_analyze_text(): def iter_fixture_dir(sub_dir): """Returns the sub-directories in any of the examplefiles/"snippets" fixture directory.""" + if not Path(TESTDIR, sub_dir).is_dir(): + return for dir in Path(TESTDIR, sub_dir).iterdir(): # Only keep directories that are not special. if (