Debian Codegraph @

debian/patches/tests-tolerate-missing-example-files.patch

raw
1 From: Colin Watson <[email protected]>
2 Date: Tue, 30 Dec 2025 18:26:20 +0000
3 Subject: Tolerate missing example files in tests
4
5 We strip tests/examplefiles from the source for licensing reasons.
6
7 Last-Update: 2025-12-30
8 ---
9 tests/test_basic_api.py | 5 -----
10 tests/test_guess.py | 2 ++
11 2 files changed, 2 insertions(+), 5 deletions(-)
12
13 diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
14 index ad9eeac..51e3e31 100644
15 --- a/tests/test_basic_api.py
16 +++ b/tests/test_basic_api.py
17 @@ -58,11 +58,6 @@ def test_lexer_classes(cls):
18 (f"Lexer class {cls.__name__} has a wrong version_added attribute. "
19 "It should be a version number like <major>.<minor> (but not "
20 "<major>.<minor>.<micro>).")
21 - if cls._example is not None:
22 - assert isinstance(cls._example, str)
23 - p = pathlib.Path(path.join(TESTDIR, "examplefiles", cls._example))
24 - assert p.is_file(), f"Example file {p} not found"
25 - assert p.parent.name in cls.aliases, f"Example file {p} not in alias directory"
26 result = cls.analyse_text("abc")
27 assert isinstance(result, float) and 0.0 <= result <= 1.0
28 result = cls.analyse_text(".abc")
29 diff --git a/tests/test_guess.py b/tests/test_guess.py
30 index fe1a2f8..4de0137 100644
31 --- a/tests/test_guess.py
32 +++ b/tests/test_guess.py
33 @@ -207,6 +207,8 @@ def test_ecl_analyze_text():
34
35 def iter_fixture_dir(sub_dir):
36 """Returns the sub-directories in any of the examplefiles/"snippets" fixture directory."""
37 + if not Path(TESTDIR, sub_dir).is_dir():
38 + return
39 for dir in Path(TESTDIR, sub_dir).iterdir():
40 # Only keep directories that are not special.
41 if (