python-chardet/hack-pytest.patch
Petr Viktorin a82491e20b Add hack to remove build dependency on python2-pytest
Since this package deals with strings, it should be tested on
Python 2 if we ship it.
However, pytest has very many dependencies, and chardet's tests
are very simple. It's not hard to run the tests without pytest.

I assume that python2-chardet will be removed from Fedora before
upstream chanes the testing mechanism, so it's OK to use this
crude hack to get rid of the python2-pytest debendency.
2019-10-03 13:57:31 +02:00

41 lines
1.3 KiB
Diff

diff -rU3 chardet-3.0.4-orig/test.py chardet-3.0.4/test.py
--- chardet-3.0.4-orig/test.py 2019-10-03 13:29:21.914988914 +0200
+++ chardet-3.0.4/test.py 2019-10-03 13:51:34.783256817 +0200
@@ -19,7 +19,27 @@
HAVE_HYPOTHESIS = True
except ImportError:
HAVE_HYPOTHESIS = False
-import pytest
+try:
+ import pytest
+except ImportError:
+ class pytest:
+ """Just enough pytest API to run the tests"""
+ class mark:
+ @staticmethod
+ def parametrize(name_string, cases):
+ """Run all given tests"""
+ def decorator(func):
+ names = name_string.split(', ')
+ for case in cases:
+ print(case)
+ func(**{name: val for name, val in zip(names, case)})
+ return decorator
+
+ @staticmethod
+ def xfail():
+ """Don't run this test"""
+ pass
+
import chardet
@@ -59,7 +79,7 @@
full_path = join(path, file_name)
test_case = full_path, encoding
if full_path in EXPECTED_FAILURES:
- test_case = pytest.param(*test_case, marks=pytest.mark.xfail)
+ continue
yield test_case