14
0

Accepting request 789030 from home:polslinux:branches:devel:languages:python

- Use pytest instead of nose
- Add remove_nose.patch

OBS-URL: https://build.opensuse.org/request/show/789030
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-entrypoint2?expand=0&rev=19
This commit is contained in:
Tomáš Chvátal
2020-03-27 13:52:47 +00:00
committed by Git OBS Bridge
parent 8b239073e0
commit c968dea0d4
3 changed files with 255 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Mar 27 13:08:03 UTC 2020 - Paolo Stivanin <info@paolostivanin.com>
- Use pytest instead of nose
- Add remove_nose.patch
-------------------------------------------------------------------
Mon Mar 2 16:33:16 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>

View File

@@ -33,6 +33,8 @@ License: BSD-2-Clause
Group: Development/Languages/Python
URL: https://github.com/ponty/entrypoint2
Source: https://github.com/ponty/entrypoint2/archive/%{version}.tar.gz#/entrypoint2-%{version}.tar.gz
# https://github.com/ponty/entrypoint2/pull/6
Patch0: remove_nose.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@@ -42,8 +44,8 @@ BuildRequires: %{python_module EasyProcess}
BuildRequires: %{python_module coverage}
BuildRequires: %{python_module decorator}
BuildRequires: %{python_module entrypoint2 = %{version}}
BuildRequires: %{python_module nose}
BuildRequires: %{python_module path.py}
BuildRequires: %{python_module pytest}
%endif
%python_subpackages
@@ -53,6 +55,7 @@ off entrypoint.
%prep
%setup -q -n entrypoint2-%{version}
%patch0 -p1
# argparse is py2.6 or older
sed -i -e '/argparse/d' requirements.txt
@@ -69,7 +72,7 @@ sed -i -e '/argparse/d' requirements.txt
%if %{with test}
%check
%python_expand nosetests-%{$python_bin_suffix}
%pytest tests/test.py
%endif
%if !%{with test}

244
remove_nose.patch Normal file
View File

@@ -0,0 +1,244 @@
diff -ru a/requirements-test.txt b/requirements-test.txt
--- a/requirements-test.txt 2020-03-27 14:00:49.587654335 +0100
+++ b/requirements-test.txt 2020-03-27 14:01:04.815678385 +0100
@@ -1,5 +1,4 @@
tox
-nose
coverage
path.py
easyprocess
\ No newline at end of file
diff -ru a/setup.py b/setup.py
--- a/setup.py 2020-03-27 14:00:49.587654335 +0100
+++ b/setup.py 2020-03-27 14:01:04.815678385 +0100
@@ -56,7 +56,6 @@
license='BSD',
packages=PACKAGES,
# include_package_data=True,
- # test_suite='nose.collector',
# zip_safe=False,
install_requires=install_requires,
# **extra
Only in entrypoint2-0.2: setup.py.orig
diff -ru a/tests/test.py b/tests/test.py
--- a/tests/test.py 2020-03-27 14:00:49.587654335 +0100
+++ b/tests/test.py 2020-03-27 14:01:08.703684524 +0100
@@ -1,5 +1,4 @@
from easyprocess import EasyProcess
-from nose.tools import eq_, ok_
from path import Path
import sys
@@ -13,133 +12,138 @@
PY3 = sys.version_info[0] >= 3
+def ported_eq(a, b, msg=None):
+ if not a == b:
+ raise AssertionError(msg or "%r != %r" % (a, b))
+
+
def test_1_call():
import example1
- eq_(example1.f(3), 3)
- eq_('description' in example1.f.__doc__, True)
- eq_(example1.f.__name__, 'f')
+ ported_eq(example1.f(3), 3)
+ ported_eq('description' in example1.f.__doc__, True)
+ ported_eq(example1.f.__name__, 'f')
def test_2_call():
import example2
- eq_(example2.f(5, 1), 6)
- eq_(example2.f.__doc__, None)
- eq_(example2.f.__name__, 'f')
+ ported_eq(example2.f(5, 1), 6)
+ ported_eq(example2.f.__doc__, None)
+ ported_eq(example2.f.__name__, 'f')
def test_3_call():
import example3
- eq_(example3.f(), 7)
- eq_(example3.f.__doc__, None)
- eq_(example3.f.__name__, 'f')
+ ported_eq(example3.f(), 7)
+ ported_eq(example3.f.__doc__, None)
+ ported_eq(example3.f.__name__, 'f')
def test_1_cli():
cmd = [python, example1_py, '5']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
cmd = [python, example1_py, '5', '--two', '7', '--debug']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
cmd = [python, example1_py, '5', '--three', '-t', '2', '--debug']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
cmd = [python, example1_py, '5', '-t', 'x']
p = EasyProcess(cmd).call()
- eq_(p.return_code > 0, 1)
- eq_(p.stdout, '')
- eq_(p.stderr != '', 1)
+ ported_eq(p.return_code > 0, 1)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr != '', 1)
cmd = [python, example1_py, '-t', '1', '5', '--debug']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
def test_2_cli():
cmd = [python, example2_py, '5', '2']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
cmd = [python, example2_py, '--debug', '5', '2']
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- ok_('root - DEBUG - 5' in p.stderr)
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ assert 'root - DEBUG - 5' in p.stderr
def test_3_cli():
cmd = [python, example3_py]
p = EasyProcess(cmd).call()
- eq_(p.return_code, 0)
- eq_(p.stdout, '')
- eq_(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '')
def test_1_ver():
cmd = [python, example1_py, '--version']
p = EasyProcess(cmd).call()
if PY3:
- eq_(p.stderr, '')
- eq_(p.stdout, '3.2')
+ ported_eq(p.stderr, '')
+ ported_eq(p.stdout, '3.2')
else:
- eq_(p.stdout, '')
- eq_(p.stderr, '3.2')
- eq_(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '3.2')
+ ported_eq(p.return_code, 0)
def test_2_ver():
cmd = [python, example2_py, '--version']
p = EasyProcess(cmd).call()
if PY3:
- eq_(p.stderr, '')
- eq_(p.stdout, '1.2')
+ ported_eq(p.stderr, '')
+ ported_eq(p.stdout, '1.2')
else:
- eq_(p.stdout, '')
- eq_(p.stderr, '1.2')
- eq_(p.return_code, 0)
+ ported_eq(p.stdout, '')
+ ported_eq(p.stderr, '1.2')
+ ported_eq(p.return_code, 0)
def test_3_ver():
cmd = [python, example3_py, '--version']
p = EasyProcess(cmd).call()
- eq_(p.stdout, '')
- ok_(p.stderr)
- ok_(p.return_code != 0)
+ ported_eq(p.stdout, '')
+ assert p.stderr
+ assert p.return_code != 0
def test_1_help():
cmd = [python, example1_py, '--help']
p = EasyProcess(cmd).call()
- eq_(p.stderr, '')
- eq_(p.return_code, 0)
- eq_('one' in p.stdout, 1)
- eq_('--two' in p.stdout, 1)
- eq_('-t' in p.stdout, 1)
- eq_('--three' in p.stdout, 1)
+ ported_eq(p.stderr, '')
+ ported_eq(p.return_code, 0)
+ ported_eq('one' in p.stdout, 1)
+ ported_eq('--two' in p.stdout, 1)
+ ported_eq('-t' in p.stdout, 1)
+ ported_eq('--three' in p.stdout, 1)
def test_2_help():
cmd = [python, example2_py, '--help']
p = EasyProcess(cmd).call()
- eq_(p.stderr, '')
- eq_(p.return_code, 0)
+ ported_eq(p.stderr, '')
+ ported_eq(p.return_code, 0)
def test_3_help():
cmd = [python, example3_py, '--help']
p = EasyProcess(cmd).call()
- eq_(p.stderr, '')
- eq_(p.return_code, 0)
+ ported_eq(p.stderr, '')
+ ported_eq(p.return_code, 0)
diff -ru a/tox.ini b/tox.ini
--- a/tox.ini 2020-03-27 14:00:49.587654335 +0100
+++ b/tox.ini 2020-03-27 14:01:04.815678385 +0100
@@ -8,12 +8,12 @@
[testenv]
deps=
- nose
+ pytest
easyprocess
path.py
setenv=
PYTHONPATH=
changedir=tests
-commands=nosetests --verbose
+commands=pytest