Skip to content

Commit 8e3754b

Browse files
committed
replace nose with pytest : init
Signed-off-by: mohapatr3 <[email protected]>
1 parent 7424fb9 commit 8e3754b

23 files changed

+303
-251
lines changed

.github/workflows/generator.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
# runtime requirements
2121
pip install -r requirements.txt
2222
# CI requirements
23-
pip install nose pylint
23+
pip install pytest pylint
2424
- name: Run tests
2525
run: |
2626
cd flatdata-generator
27-
python -m nose
27+
python -m pytest
2828
pip install .
2929
flatdata-generator --help

.github/workflows/py.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
# runtime requirements
2222
pip install -r requirements.txt
2323
# CI requirements
24-
pip install nose pylint
24+
pip install pytest pylint
2525
- name: Run tests
2626
run: |
2727
cd flatdata-py
28-
python -m nose
28+
python -m pytest
2929
pip install .
3030
flatdata-inspector --help

flatdata-cpp/ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN apk --no-cache add \
1616
breathe \
1717
sphinx \
1818
jinja2 \
19-
nose \
19+
pytest \
2020
pandas \
2121
pyparsing
2222

flatdata-generator/pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
testpaths = tests
3+
python_files = test_*.py
4+
python_classes = Test*
5+
python_functions = test_*

flatdata-generator/tests/generators/test_cpp_generator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from .assertions import generate_and_assert_in
99
from .schemas import schemas_and_expectations
1010

11+
import pytest
12+
1113
def generate_and_compare(test_case):
1214
with open(test_case[0], 'r') as test_file:
1315
test = test_file.read()
@@ -21,4 +23,7 @@ def generate_and_compare(test_case):
2123

2224
def test_against_expectations():
2325
for x in schemas_and_expectations(generator='cpp', extension='h'):
24-
yield generate_and_compare, x
26+
@pytest.fixture
27+
def inner_fixture():
28+
yield generate_and_compare, x
29+
inner_fixture

flatdata-generator/tests/generators/test_dot_generator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from .assertions import generate_and_assert_in
99
from .schemas import schemas_and_expectations
1010

11+
import pytest
12+
1113
def test_structures_outside_of_archives_are_not_represented():
1214
unexpected_lines = [
1315
"_n_S"
@@ -33,4 +35,7 @@ def generate_and_compare(test_case):
3335

3436
def test_against_expectations():
3537
for x in schemas_and_expectations(generator='dot', extension='dot'):
36-
yield generate_and_compare, x
38+
@pytest.fixture
39+
def inner_fixture():
40+
yield generate_and_compare, x
41+
inner_fixture

flatdata-generator/tests/generators/test_flatdata_generator.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,33 @@
22
Copyright (c) 2018 HERE Europe B.V.
33
See the LICENSE file in the root of this project for license details.
44
'''
5-
from nose.tools import assert_equal
5+
import pytest
66

77
from flatdata.generator.generators.flatdata import FlatdataGenerator
88
from flatdata.generator.tree.builder import build_ast
99
from .schemas import schemas_and_expectations
1010

11+
import pytest
12+
1113
def generate_and_compare(test_case):
1214
with open(test_case[0], 'r') as test_file:
1315
test = test_file.read()
1416
with open(test_case[1], 'r') as expectation_file:
1517
expectation = expectation_file.read()
1618
tree = build_ast(definition=test)
1719
contents = FlatdataGenerator().render(tree)
18-
assert_equal.__self__.maxDiff = None
19-
assert_equal(expectation, contents, test_case)
20+
assert expectation == contents
2021

2122
def test_against_expectations():
2223
for i in schemas_and_expectations(generator='flatdata', extension='flatdata'):
23-
yield generate_and_compare, i
24+
@pytest.fixture
25+
def inner_fixture():
26+
yield generate_and_compare, x
27+
inner_fixture
2428

2529
def test_normalization_is_fixed_point():
2630
for i in schemas_and_expectations(generator='flatdata', extension='flatdata'):
27-
yield generate_and_compare, (i[1], i[1])
31+
@pytest.fixture
32+
def inner_fixture():
33+
yield generate_and_compare, (i[1], i[1])
34+
inner_fixture

flatdata-generator/tests/generators/test_go_generator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .assertions import generate_and_assert_in
99
from .schemas import schemas_and_expectations
1010

11-
from nose.plugins.skip import SkipTest
11+
import pytest
1212

1313

1414
def generate_and_compare(test_case):
@@ -24,13 +24,19 @@ def generate_and_compare(test_case):
2424

2525

2626
def skip(test_case):
27-
raise SkipTest("Test %s is skipped" % test_case[0])
27+
raise pytest.skip("Test %s is skipped" % test_case[0])
2828

2929

3030
def test_against_expectations():
3131
for x in schemas_and_expectations(generator='go', extension='go'):
3232
# Go does not yet support namespaces, enums, ranges, or constants, skip those tests
3333
if "enums" not in x[0] and "constants" not in x[0] and "namespaces" not in x[0] and "ranges" not in x[0]:
34-
yield generate_and_compare, x
34+
@pytest.fixture
35+
def inner_fixture():
36+
yield generate_and_compare, x
37+
inner_fixture
3538
else:
36-
yield skip, x
39+
@pytest.fixture
40+
def inner_fixture():
41+
yield skip, x
42+
inner_fixture

flatdata-generator/tests/generators/test_python_generator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .assertions import generate_and_assert_in
99
from .schemas import schemas_and_expectations
1010

11-
from nose.plugins.skip import SkipTest
11+
import pytest
1212

1313
def generate_and_compare(test_case):
1414
with open(test_case[0], 'r') as test_file:
@@ -22,12 +22,18 @@ def generate_and_compare(test_case):
2222
generate_and_assert_in(test, PythonGenerator, *expectations)
2323

2424
def skip(test_case):
25-
raise SkipTest("Test %s is skipped" % test_case[0])
25+
raise pytest.skip("Test %s is skipped" % test_case[0])
2626

2727
def test_against_expectations():
2828
for x in schemas_and_expectations(generator='py', extension='py'):
2929
# Python does not yet support enums or constants, skip those tests
3030
if "enums" not in x[0] and "constants" not in x[0]:
31-
yield generate_and_compare, x
31+
@pytest.fixture
32+
def inner_fixture():
33+
yield generate_and_compare, x
34+
inner_fixture
3235
else:
33-
yield skip, x
36+
@pytest.fixture
37+
def inner_fixture():
38+
yield skip, x
39+
inner_fixture

flatdata-generator/tests/generators/test_rust_generator.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
See the LICENSE file in the root of this project for license details.
44
'''
55
import glob
6-
from nose.tools import eq_
6+
import pytest
77

88
from flatdata.generator.generators.rust import RustGenerator
99
from .assertions import generate_and_assert_in
1010
from .schemas import schemas_and_expectations
1111

1212
def test_format_numeric_literals():
13-
eq_(RustGenerator._format_numeric_literal(1), "1")
14-
eq_(RustGenerator._format_numeric_literal(123), "123")
15-
eq_(RustGenerator._format_numeric_literal(-123), "-123")
16-
eq_(RustGenerator._format_numeric_literal(1), "1")
17-
eq_(RustGenerator._format_numeric_literal(10), "10")
18-
eq_(RustGenerator._format_numeric_literal(100), "100")
19-
eq_(RustGenerator._format_numeric_literal(1000), "1_000")
20-
eq_(RustGenerator._format_numeric_literal(10000), "10_000")
21-
eq_(RustGenerator._format_numeric_literal(100000), "100_000")
22-
eq_(RustGenerator._format_numeric_literal(1000000), "1_000_000")
23-
eq_(RustGenerator._format_numeric_literal(-1000000), "-1_000_000")
24-
eq_(RustGenerator._format_numeric_literal(2147483647), "2_147_483_647")
25-
eq_(RustGenerator._format_numeric_literal("hello"), "hello")
26-
eq_(RustGenerator._format_numeric_literal("hello1234"), "hello1234")
27-
eq_(RustGenerator._format_numeric_literal("1234hello"), "1234hello")
13+
assert RustGenerator._format_numeric_literal(1) == "1"
14+
assert RustGenerator._format_numeric_literal(123) == "123"
15+
assert RustGenerator._format_numeric_literal(-123) == "-123"
16+
assert RustGenerator._format_numeric_literal(1) == "1"
17+
assert RustGenerator._format_numeric_literal(10) == "10"
18+
assert RustGenerator._format_numeric_literal(100) == "100"
19+
assert RustGenerator._format_numeric_literal(1000) == "1_000"
20+
assert RustGenerator._format_numeric_literal(10000) == "10_000"
21+
assert RustGenerator._format_numeric_literal(100000) == "100_000"
22+
assert RustGenerator._format_numeric_literal(1000000) == "1_000_000"
23+
assert RustGenerator._format_numeric_literal(-1000000) == "-1_000_000"
24+
assert RustGenerator._format_numeric_literal(2147483647) == "2_147_483_647"
25+
assert RustGenerator._format_numeric_literal("hello") == "hello"
26+
assert RustGenerator._format_numeric_literal("hello1234") == "hello1234"
27+
assert RustGenerator._format_numeric_literal("1234hello") == "1234hello"
2828

2929
def generate_and_compare(test_case):
3030
with open(test_case[0], 'r') as test_file:
@@ -39,4 +39,7 @@ def generate_and_compare(test_case):
3939

4040
def test_against_expectations():
4141
for x in schemas_and_expectations(generator='rust', extension='rs'):
42-
yield generate_and_compare, x
42+
@pytest.fixture
43+
def inner_fixture():
44+
yield generate_and_compare, x
45+
inner_fixture

0 commit comments

Comments
 (0)