Skip to content

Commit 08c051b

Browse files
committed
replace nose with pytest
Signed-off-by: mohapatr3 <[email protected]>
1 parent 192c309 commit 08c051b

25 files changed

+278
-275
lines changed

.github/workflows/generator.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ env:
1111

1212
jobs:
1313
Build:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v2
17+
- name: Dependencies
18+
uses: astral-sh/setup-uv@v6
1719
- name: Install
1820
run: |
1921
cd flatdata-generator
2022
# runtime requirements
2123
pip install -r requirements.txt
2224
# CI requirements
23-
pip install nose pylint
25+
pip install pylint
2426
- name: Run tests
2527
run: |
2628
cd flatdata-generator
27-
python -m nose
29+
uv run --with pytest pytest
2830
pip install .
2931
flatdata-generator --help

.github/workflows/py.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ env:
1111

1212
jobs:
1313
Build:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v2
17+
- name: Dependencies
18+
uses: astral-sh/setup-uv@v6
1719
- name: Install
1820
run: |
1921
pip install ./flatdata-generator
2022
cd flatdata-py
2123
# runtime requirements
2224
pip install -r requirements.txt
2325
# CI requirements
24-
pip install nose pylint
26+
pip install pylint
2527
- name: Run tests
2628
run: |
2729
cd flatdata-py
28-
python -m nose
30+
uv run --with pytest --with ../flatdata-generator pytest
2931
pip install .
3032
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/pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ include = [
3333

3434
[tool.hatch.build.targets.wheel]
3535
packages = ["flatdata"]
36+
37+
[tool.pytest.ini_options]
38+
testpaths = [ "tests" ]
39+
python_files = [ "test_*.py" ]
40+
python_classes = [ "Test*" ]
41+
python_functions = [ "test_*" ]

flatdata-generator/tests/generators/test_cpp_generator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'''
2-
Copyright (c) 2019 HERE Europe B.V.
2+
Copyright (c) 2025 HERE Europe B.V.
33
See the LICENSE file in the root of this project for license details.
44
'''
55
import glob
6+
import pytest
67

78
from flatdata.generator.generators.cpp import CppGenerator
89
from .assertions import generate_and_assert_in
910
from .schemas import schemas_and_expectations
1011

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,4 @@ 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+
generate_and_compare(x)

flatdata-generator/tests/generators/test_dot_generator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'''
2-
Copyright (c) 2017 HERE Europe B.V.
2+
Copyright (c) 2025 HERE Europe B.V.
33
See the LICENSE file in the root of this project for license details.
44
'''
55
import glob
6+
import pytest
67

78
from flatdata.generator.generators.dot import DotGenerator
89
from .assertions import generate_and_assert_in
910
from .schemas import schemas_and_expectations
1011

12+
1113
def test_structures_outside_of_archives_are_not_represented():
1214
unexpected_lines = [
1315
"_n_S"
@@ -33,4 +35,4 @@ 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+
generate_and_compare(x)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
'''
2-
Copyright (c) 2018 HERE Europe B.V.
2+
Copyright (c) 2025 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+
1112
def generate_and_compare(test_case):
1213
with open(test_case[0], 'r') as test_file:
1314
test = test_file.read()
1415
with open(test_case[1], 'r') as expectation_file:
1516
expectation = expectation_file.read()
1617
tree = build_ast(definition=test)
1718
contents = FlatdataGenerator().render(tree)
18-
assert_equal.__self__.maxDiff = None
19-
assert_equal(expectation, contents, test_case)
19+
assert expectation == contents
2020

2121
def test_against_expectations():
2222
for i in schemas_and_expectations(generator='flatdata', extension='flatdata'):
23-
yield generate_and_compare, i
23+
generate_and_compare((i[1], i[1]))
2424

2525
def test_normalization_is_fixed_point():
2626
for i in schemas_and_expectations(generator='flatdata', extension='flatdata'):
27-
yield generate_and_compare, (i[1], i[1])
27+
generate_and_compare((i[1], i[1]))

flatdata-generator/tests/generators/test_go_generator.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'''
2-
Copyright (c) 2017 HERE Europe B.V.
2+
Copyright (c) 2025 HERE Europe B.V.
33
See the LICENSE file in the root of this project for license details.
44
'''
55
import glob
6+
import pytest
67

78
from flatdata.generator.generators.go import GoGenerator
89
from .assertions import generate_and_assert_in
910
from .schemas import schemas_and_expectations
1011

11-
from nose.plugins.skip import SkipTest
12-
1312

1413
def generate_and_compare(test_case):
1514
with open(test_case[0], 'r') as test_file:
@@ -24,13 +23,13 @@ def generate_and_compare(test_case):
2423

2524

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

2928

3029
def test_against_expectations():
3130
for x in schemas_and_expectations(generator='go', extension='go'):
3231
# Go does not yet support namespaces, enums, ranges, or constants, skip those tests
3332
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
33+
generate_and_compare(x)
3534
else:
36-
yield skip, x
35+
skip(x)

flatdata-generator/tests/generators/test_python_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'''
2-
Copyright (c) 2017 HERE Europe B.V.
2+
Copyright (c) 2025 HERE Europe B.V.
33
See the LICENSE file in the root of this project for license details.
44
'''
55
import glob
6+
import pytest
67

78
from flatdata.generator.generators.python import PythonGenerator
89
from .assertions import generate_and_assert_in
910
from .schemas import schemas_and_expectations
1011

11-
from nose.plugins.skip import SkipTest
1212

1313
def generate_and_compare(test_case):
1414
with open(test_case[0], 'r') as test_file:
@@ -22,12 +22,12 @@ 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+
generate_and_compare(x)
3232
else:
33-
yield skip, x
33+
skip(x)
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
'''
2-
Copyright (c) 2019 HERE Europe B.V.
2+
Copyright (c) 2025 HERE Europe B.V.
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,4 @@ 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+
generate_and_compare(x)

0 commit comments

Comments
 (0)