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.
This commit is contained in:
parent
d947672d8f
commit
a82491e20b
2 changed files with 49 additions and 3 deletions
41
hack-pytest.patch
Normal file
41
hack-pytest.patch
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
%global pypi_name chardet
|
||||
Name: python-%{pypi_name}
|
||||
Version: 3.0.4
|
||||
Release: 12%{?dist}
|
||||
Release: 13%{?dist}
|
||||
Summary: Character encoding auto-detection in Python
|
||||
License: LGPLv2
|
||||
URL: https://github.com/%{pypi_name}/%{pypi_name}
|
||||
|
|
@ -10,6 +10,9 @@ Source0: %pypi_source
|
|||
# pytest 4 support
|
||||
Patch1: https://github.com/chardet/chardet/pull/174.patch
|
||||
|
||||
# Don't require python2-pytest
|
||||
Patch2: hack-pytest.patch
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: python2-devel
|
||||
BuildRequires: python2-setuptools
|
||||
|
|
@ -20,7 +23,6 @@ BuildRequires: python3-setuptools
|
|||
# Circular dependency on pytest
|
||||
%bcond_without tests
|
||||
%if %{with tests}
|
||||
BuildRequires: python2-pytest
|
||||
BuildRequires: python3-pytest
|
||||
%endif
|
||||
|
||||
|
|
@ -62,7 +64,7 @@ rm %{buildroot}%{_bindir}/*
|
|||
|
||||
%if %{with tests}
|
||||
%check
|
||||
%{__python2} -m pytest -v
|
||||
%{__python2} test.py
|
||||
%{__python3} -m pytest -v
|
||||
%endif
|
||||
|
||||
|
|
@ -81,6 +83,9 @@ rm %{buildroot}%{_bindir}/*
|
|||
|
||||
|
||||
%changelog
|
||||
* Thu Oct 03 2019 Petr Viktorin <pviktori@redhat.com> - 3.0.4-13
|
||||
- Add hack to remove build dependency on python2-pytest
|
||||
|
||||
* Thu Aug 15 2019 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-12
|
||||
- Rebuilt for Python 3.8
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue