Skip to content

Commit dd419f3

Browse files
committed
switch to pytest, as nose is not maintained anymore
1 parent 289403c commit dd419f3

File tree

6 files changed

+77
-82
lines changed

6 files changed

+77
-82
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ install:
1010
- "pip install -r test_requirements.txt"
1111
- "./setup.py develop"
1212
- "pip install coveralls"
13-
- "pip install nose"
13+
- "pip install pytest"
1414
- "pip install mypy"
15-
script:
15+
script:
1616
- export PYTHONPATH=./src:$PYTHONPATH
1717
- coverage erase
18-
- coverage run --source=pyff setup.py test
18+
- make test
1919
- mv .coverage .coverage.1
2020
- coverage combine
2121
- make typecheck

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
SOURCE= src
1+
TOPDIR:= $(abspath .)
2+
SRCDIR= $(TOPDIR)/src
3+
SOURCE= $(SRCDIR)/pyff
4+
5+
test:
6+
PYTHONPATH=$(SRCDIR) pytest
27

38
reformat:
49
isort --line-width 120 --atomic --project eduid_scimapi --recursive $(SOURCE)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ httplib2 >=0.7.7
66
ipaddr
77
lxml >=4.1.1
88
mako
9-
nose
109
pyXMLSecurity >=0.15
1110
pyconfig
1211
pyramid

setup.py

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
__author__ = 'Leif Johansson'
1515
__version__ = '2.0.0'
1616

17+
1718
def load_requirements(path: PurePath) -> List[str]:
1819
""" Load dependencies from a requirements.txt style file, ignoring comments etc. """
1920
res = []
@@ -27,6 +28,7 @@ def load_requirements(path: PurePath) -> List[str]:
2728
res += [line]
2829
return res
2930

31+
3032
here = PurePath(__file__)
3133
README = open(here.with_name('README.rst')).read()
3234
NEWS = open(here.with_name('NEWS.txt')).read()
@@ -36,45 +38,35 @@ def load_requirements(path: PurePath) -> List[str]:
3638

3739
python_implementation_str = python_implementation()
3840

39-
setup(name='pyFF',
40-
version=__version__,
41-
description="Federation Feeder",
42-
long_description=README + '\n\n' + NEWS,
43-
classifiers=[
44-
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
45-
'Programming Language :: Python :: 3',
46-
'Programming Language :: Python :: 3.7',
47-
'Programming Language :: Python :: 3.8',
48-
],
49-
keywords='identity federation saml metadata',
50-
author=__author__,
51-
author_email='leifj@sunet.se',
52-
url='https://pyff.io',
53-
license='BSD',
54-
setup_requires=['nose>=1.0'],
55-
tests_require=tests_require,
56-
test_suite="nose.collector",
57-
packages=find_packages('src'),
58-
package_dir={'': 'src'},
59-
include_package_data=True,
60-
package_data={
61-
'pyff': ['xslt/*.xsl', 'schema/*.xsd']
62-
},
63-
zip_safe=False,
64-
install_requires=install_requires,
65-
scripts=['scripts/mirror-mdq.sh'],
66-
entry_points={
67-
'console_scripts': ['pyff=pyff.md:main', 'pyffd=pyff.mdq:main', 'samldiff=pyff.tools:difftool'],
68-
'paste.app_factory': [
69-
'pyffapp=pyff.wsgi:app_factory'
70-
],
71-
'paste.server_runner': [
72-
'pyffs=pyff.wsgi:server_runner'
73-
],
74-
},
75-
message_extractors={'src': [
76-
('**.py', 'python', None),
77-
('**/templates/**.html', 'mako', None),
78-
]},
79-
python_requires='>=3.7',
80-
)
41+
setup(
42+
name='pyFF',
43+
version=__version__,
44+
description="Federation Feeder",
45+
long_description=README + '\n\n' + NEWS,
46+
classifiers=[
47+
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
48+
'Programming Language :: Python :: 3',
49+
'Programming Language :: Python :: 3.7',
50+
'Programming Language :: Python :: 3.8',
51+
],
52+
keywords='identity federation saml metadata',
53+
author=__author__,
54+
author_email='leifj@sunet.se',
55+
url='https://pyff.io',
56+
license='BSD',
57+
tests_require=tests_require,
58+
packages=find_packages('src'),
59+
package_dir={'': 'src'},
60+
include_package_data=True,
61+
package_data={'pyff': ['xslt/*.xsl', 'schema/*.xsd']},
62+
zip_safe=False,
63+
install_requires=install_requires,
64+
scripts=['scripts/mirror-mdq.sh'],
65+
entry_points={
66+
'console_scripts': ['pyff=pyff.md:main', 'pyffd=pyff.mdq:main', 'samldiff=pyff.tools:difftool'],
67+
'paste.app_factory': ['pyffapp=pyff.wsgi:app_factory'],
68+
'paste.server_runner': ['pyffs=pyff.wsgi:server_runner'],
69+
},
70+
message_extractors={'src': [('**.py', 'python', None), ('**/templates/**.html', 'mako', None),]},
71+
python_requires='>=3.7',
72+
)

src/pyff/test/test_pipeline.py

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import tempfile
55

6+
import pytest
67
import six
78
import yaml
89
from mako.lookup import TemplateLookup
@@ -24,6 +25,20 @@
2425

2526

2627
class PipeLineTest(SignerTestCase):
28+
@pytest.fixture(autouse=True)
29+
def _capsys(self, capsys):
30+
self.capsys = capsys
31+
32+
@property
33+
def captured_stdout(self):
34+
out, _err = self.capsys.readouterr()
35+
return out
36+
37+
@property
38+
def captured_stderr(self):
39+
_out, err = self.capsys.readouterr()
40+
return err
41+
2742
def run_pipeline(self, pl_name, ctx=None, md=None):
2843
if ctx is None:
2944
ctx = dict()
@@ -56,19 +71,6 @@ def setUp(self):
5671
self.templates = TemplateLookup(directories=[os.path.join(self.datadir, 'simple-pipeline')])
5772

5873

59-
class StreamCapturing(object):
60-
def __init__(self, stream):
61-
self.captured = []
62-
self.stream = stream
63-
64-
def __getattr__(self, attr):
65-
return getattr(self.stream, attr)
66-
67-
def write(self, data):
68-
self.captured.append(data)
69-
self.stream.write(data)
70-
71-
7274
class ParseTest(PipeLineTest):
7375
def parse_test(self):
7476
self.output = tempfile.NamedTemporaryFile('w').name
@@ -456,23 +458,22 @@ def test_cert_report_swamid(self):
456458
print(fd.read())
457459

458460
def test_info_and_dump(self):
459-
with patch("sys.stdout", StreamCapturing(sys.stdout)) as ctx:
460-
try:
461-
self.exec_pipeline(
462-
"""
461+
try:
462+
self.exec_pipeline(
463+
"""
463464
- load:
464465
- http://mds.swamid.se/md/swamid-2.0.xml
465466
- select
466467
- dump
467468
- info
468469
"""
469-
)
470-
assert 'https://idp.nordu.net/idp/shibboleth' in sys.stdout.captured
471-
except IOError:
472-
pass
470+
)
471+
assert 'https://idp.nordu.net/idp/shibboleth' in self.captured_stdout
472+
except IOError:
473+
pass
473474

474475
def test_end_exit(self):
475-
with patch.multiple("sys", exit=self.sys_exit, stdout=StreamCapturing(sys.stdout)):
476+
with patch.multiple("sys", exit=self.sys_exit):
476477
try:
477478
self.exec_pipeline(
478479
"""
@@ -486,21 +487,18 @@ def test_end_exit(self):
486487
pass
487488
except ExitException as ex:
488489
assert ex.code == 22
489-
assert "slartibartifast" in "".join(sys.stdout.captured)
490+
assert "slartibartifast" in self.captured_stdout
490491

491492
def test_single_dump(self):
492-
with patch.multiple("sys", exit=self.sys_exit, stdout=StreamCapturing(sys.stdout)):
493-
try:
494-
self.exec_pipeline(
495-
"""
493+
try:
494+
self.exec_pipeline(
495+
"""
496496
- dump
497497
"""
498-
)
499-
assert '<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"/>' in "".join(
500-
sys.stdout.captured
501-
)
502-
except IOError:
503-
pass
498+
)
499+
assert '<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"/>' in self.captured_stdout
500+
except IOError:
501+
pass
504502

505503
def test_missing_select(self):
506504
for stmt in (

test_requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
coverage
22
fakeredis>=1.0.5
33
funcsigs
4+
isort
45
mako
56
mock
6-
nose>=1.0
77
pbr
8+
pytest
9+
pytest-cov
810
setuptools
911
testfixtures
1012
wsgi_intercept
11-
isort

0 commit comments

Comments
 (0)