Skip to content

Commit 0c03123

Browse files
committed
Switch from nose to pytest
1 parent 140258a commit 0c03123

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
pip install dist/*.whl
2626
- name: Test with pytest
2727
run: |
28-
cd tests/ && nosetests --with-coverage --cover-package jmespath .
28+
cd tests/ && py.test --cov jmespath --cov-report term-missing

requirements.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
nose==1.2.1
2-
py==1.10.0
3-
tox==1.4.2
1+
pytest==6.2.5
42
wheel==0.24.0
5-
coverage==5.3 ; python_version == '3.9'
6-
coverage==5.0.3 ; python_version == '3.8'
7-
coverage==3.7.1 ; python_version < '3.8'
3+
pytest-cov==3.0.0
84
hypothesis==3.1.0 ; python_version < '3.8'
95
hypothesis==5.5.4 ; python_version == '3.8'
106
hypothesis==5.35.4 ; python_version == '3.9'
11-
typing<3.7.4 ; python_version == '3.3'

tests/test_compliance.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tests import OrderedDict
44
from tests import json
55

6-
from nose.tools import assert_equal
6+
import pytest
77

88
from jmespath.visitor import Options
99

@@ -15,19 +15,19 @@
1515
OPTIONS = Options(dict_cls=OrderedDict)
1616

1717

18-
def test_compliance():
18+
def _compliance_tests(requested_test_type):
1919
for full_path in _walk_files():
2020
if full_path.endswith('.json'):
2121
for given, test_type, test_data in load_cases(full_path):
2222
t = test_data
2323
# Benchmark tests aren't run as part of the normal
2424
# test suite, so we only care about 'result' and
2525
# 'error' test_types.
26-
if test_type == 'result':
27-
yield (_test_expression, given, t['expression'],
26+
if test_type == 'result' and test_type == requested_test_type:
27+
yield (given, t['expression'],
2828
t['result'], os.path.basename(full_path))
29-
elif test_type == 'error':
30-
yield (_test_error_expression, given, t['expression'],
29+
elif test_type == 'error' and test_type == requested_test_type:
30+
yield (given, t['expression'],
3131
t['error'], os.path.basename(full_path))
3232

3333

@@ -63,7 +63,11 @@ def load_cases(full_path):
6363
yield (given, test_type, case)
6464

6565

66-
def _test_expression(given, expression, expected, filename):
66+
@pytest.mark.parametrize(
67+
'given, expression, expected, filename',
68+
_compliance_tests('result')
69+
)
70+
def test_expression(given, expression, expected, filename):
6771
import jmespath.parser
6872
try:
6973
parsed = jmespath.compile(expression)
@@ -80,10 +84,14 @@ def _test_expression(given, expression, expected, filename):
8084
actual_repr, pformat(parsed.parsed),
8185
json.dumps(given, indent=4)))
8286
error_msg = error_msg.replace(r'\n', '\n')
83-
assert_equal(actual, expected, error_msg)
87+
assert actual == expected, error_msg
8488

8589

86-
def _test_error_expression(given, expression, error, filename):
90+
@pytest.mark.parametrize(
91+
'given, expression, error, filename',
92+
_compliance_tests('error')
93+
)
94+
def test_error_expression(given, expression, error, filename):
8795
import jmespath.parser
8896
if error not in ('syntax', 'invalid-type',
8997
'unknown-function', 'invalid-arity', 'invalid-value'):

0 commit comments

Comments
 (0)