Modernize spec

Run tests properly, skip tests that require xdist for now
epel8
Orion Poplawski 10 years ago
parent 2c7ec30f61
commit 7e71bb9e0b

@ -0,0 +1,126 @@
diff -up pytest-cov-2.1.0/tests/test_pytest_cov.py.xdist pytest-cov-2.1.0/tests/test_pytest_cov.py
--- pytest-cov-2.1.0/tests/test_pytest_cov.py.xdist 2015-08-22 18:04:15.000000000 -0600
+++ pytest-cov-2.1.0/tests/test_pytest_cov.py 2015-09-14 10:29:43.633141009 -0600
@@ -102,6 +102,12 @@ def test_run_target():
p.join()
'''
+try:
+ import xdist
+ HAS_XDIST = True
+except:
+ HAS_XDIST = False
+
SCRIPT_FAIL = '''
def test_fail():
assert False
@@ -113,7 +119,11 @@ SCRIPT2_RESULT = '3 * 100%'
CHILD_SCRIPT_RESULT = '6 * 100%'
PARENT_SCRIPT_RESULT = '8 * 100%'
-xdist = pytest.mark.parametrize('opts', ['', '-n 1'], ids=['nodist', 'xdist'])
+try:
+ import xdist
+ xdist = pytest.mark.parametrize('opts', ['', '-n 1'], ids=['nodist', 'xdist'])
+except:
+ xdist = pytest.mark.parametrize('opts', [''], ids=['nodist'])
def test_central(testdir):
@@ -253,6 +263,7 @@ show_missing = true
assert result.ret == 0
+@pytest.mark.skipif("not HAS_XDIST")
def test_no_cov_on_fail(testdir):
script = testdir.makepyfile(SCRIPT_FAIL)
@@ -266,6 +277,7 @@ def test_no_cov_on_fail(testdir):
result.stdout.fnmatch_lines(['*1 failed*'])
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_combine_racecondition(testdir):
script = testdir.makepyfile("""
import pytest
@@ -292,6 +304,7 @@ def test_foo(foo):
assert result.ret == 0
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_collocated(testdir):
script = testdir.makepyfile(SCRIPT)
@@ -311,6 +324,7 @@ def test_dist_collocated(testdir):
assert result.ret == 0
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_not_collocated(testdir):
script = testdir.makepyfile(SCRIPT)
dir1 = testdir.mkdir('dir1')
@@ -376,6 +390,7 @@ omit =
assert result.ret == 0
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_subprocess_collocated(testdir):
scripts = testdir.makepyfile(parent_script=SCRIPT_PARENT,
child_script=SCRIPT_CHILD)
@@ -397,6 +412,7 @@ def test_dist_subprocess_collocated(test
assert result.ret == 0
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_subprocess_not_collocated(testdir, tmpdir):
scripts = testdir.makepyfile(parent_script=SCRIPT_PARENT,
child_script=SCRIPT_CHILD)
@@ -442,6 +458,7 @@ def test_empty_report(testdir):
assert not matching_lines
+@pytest.mark.skipif("not HAS_XDIST")
def test_dist_missing_data(testdir):
venv_path = os.path.join(str(testdir.tmpdir), 'venv')
virtualenv.create_environment(venv_path)
@@ -548,6 +565,7 @@ def test_cover_conftest(testdir):
result.stdout.fnmatch_lines([CONF_RESULT])
+@pytest.mark.skipif("not HAS_XDIST")
def test_cover_looponfail(testdir, monkeypatch):
testdir.makepyfile(mod=MODULE)
testdir.makeconftest(CONFTEST)
@@ -566,6 +584,7 @@ def test_cover_looponfail(testdir, monke
)
+@pytest.mark.skipif("not HAS_XDIST")
def test_cover_conftest_dist(testdir):
testdir.makepyfile(mod=MODULE)
testdir.makeconftest(CONFTEST)
@@ -615,6 +634,7 @@ def test_coveragerc(testdir):
result.stdout.fnmatch_lines(['test_coveragerc* %s' % EXCLUDED_RESULT])
+@pytest.mark.skipif("not HAS_XDIST")
def test_coveragerc_dist(testdir):
testdir.makefile('', coveragerc=COVERAGERC)
script = testdir.makepyfile(EXCLUDED_TEST)
@@ -661,7 +681,7 @@ def test_foo():
SCRIPT_SIMPLE_RESULT = '4 * 100%'
-@pytest.mark.skipif('sys.platform == "win32"')
+@pytest.mark.skipif('sys.platform == "win32" or not HAS_XDIST')
def test_dist_boxed(testdir):
script = testdir.makepyfile(SCRIPT_SIMPLE)
@@ -737,6 +757,7 @@ data_file = %s
assert glob.glob(str(testdir.tmpdir.join('some/special/place/coverage-data*')))
+@pytest.mark.skipif("not HAS_XDIST")
def test_external_data_file_xdist(testdir):
script = testdir.makepyfile(SCRIPT)
testdir.tmpdir.join('.coveragerc').write("""

@ -16,14 +16,21 @@ Summary: Pytest plugin for coverage reporting
License: MIT
URL: https://pypi.python.org/pypi/%{srcname}
Source0: https://pypi.python.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz
# Skip xdist tests, not yet packaged
Patch0: python-pytest-cov-xdist.patch
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-setuptools
BuildRequires: pytest
BuildRequires: python-cov-core
BuildRequires: python-coverage >= 3.7.1
# For tests
BuildRequires: python-process-tests
BuildRequires: python-virtualenv
Requires: pytest
Requires: python-cov-core
Requires: python-coverage >= 3.7.1
Provides: python2-%{srcname} = %{version}-%{release}
%description
Py.test plugin for coverage reporting with support for both centralised and
@ -36,9 +43,12 @@ Summary: Pytest plugin for coverage reporting
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pytest
BuildRequires: python3-cov-core
BuildRequires: python3-coverage >= 3.7.1
# For tests
BuildRequires: python3-process-tests
BuildRequires: python3-virtualenv
Requires: python3-pytest
Requires: python3-cov-core
Requires: python3-coverage >= 3.7.1
%description -n python3-%{srcname}
Py.test plugin for coverage reporting with support for both centralised and
@ -48,57 +58,50 @@ distributed testing, including subprocesses and multiprocessing for Python 3.
%prep
%setup -q -n %{srcname}-%{version}
%patch0 -p1 -b .xdist
rm -rf *.egg-info
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif # with_python3
%build
%{__python2} setup.py build
%py2_build
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%py3_build
%endif # with_python3
%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
popd
%py3_install
%endif # with_python3
%{__python2} setup.py install --skip-build --root %{buildroot}
%py2_install
%check
%{__python2} setup.py test
PYTHONPATH=%{buildroot}%{python2_sitelib}:$PWD/tests py.test-%{python2_version} -vv
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py test
popd
PYTHONPATH=%{buildroot}%{python3_sitelib}:$PWD/tests py.test-%{python3_version} -vv
%endif # with_python3
%files
%doc LICENSE PKG-INFO README.rst
%license LICENSE
%doc AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst README.rst
%{python2_sitelib}/*
%if 0%{?with_python3}
%files -n python3-%{srcname}
%doc LICENSE PKG-INFO README.rst
%license LICENSE
%doc AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst README.rst
%{python3_sitelib}/*
%endif # with_python3
%changelog
* Mon Sep 14 2015 Orion Poplawski <orion@cora.nwra.com> - 2.1.0-2
- Modernize spec
- Run tests properly, skipping xdist tests for now
* Mon Sep 14 2015 Tomas Tomecek <ttomecek@redhat.com> - 2.1.0-1
- upstream release 2.1.0

Loading…
Cancel
Save