File: tests-tolerate-missing-example-files.patch

package info (click to toggle)
pygments 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,668 kB
  • sloc: python: 105,287; javascript: 238; makefile: 142; sh: 84; lisp: 74
file content (46 lines) | stat: -rw-r--r-- 1,795 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From: Colin Watson <cjwatson@debian.org>
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 | 10 ----------
 tests/test_guess.py     |  2 ++
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 659163f..91cfbb6 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -60,16 +60,6 @@ def test_lexer_classes(cls):
             (f"Lexer class {cls.__name__} has a wrong version_added attribute. "
              "It should be a version number like <major>.<minor> (but not "
              "<major>.<minor>.<micro>).")
-    if cls._example is not None:
-        assert isinstance(cls._example, str)
-        p = (
-            pathlib.Path(inspect.getabsfile(pygments)).parent.parent
-            / "tests"
-            / "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 10818cc..3a1f2dd 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 (