forked from heremaps/flatdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_python_generator.py
More file actions
39 lines (31 loc) · 1.2 KB
/
test_python_generator.py
File metadata and controls
39 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'''
Copyright (c) 2025 HERE Europe B.V.
See the LICENSE file in the root of this project for license details.
'''
import glob
import pytest
from flatdata.generator.generators.python import PythonGenerator
from .assertions import generate_and_assert_in
from .schemas import schemas_and_expectations
def generate_and_compare(test_case):
with open(test_case[0], 'r') as test_file:
test = test_file.read()
expectations = list()
for file in glob.glob(test_case[1] + '*'):
with open(file, 'r') as expectation_file:
expectations.append(expectation_file.read())
generate_and_assert_in(test, PythonGenerator, *expectations)
def skip(test_case):
raise pytest.skip("Test %s is skipped" % test_case[0])
def get_test_cases():
test_cases = []
for x in schemas_and_expectations(generator='py', extension='py'):
test_cases.append(x)
return test_cases
@pytest.mark.parametrize("test_case", get_test_cases())
def test_against_expectations(test_case):
# Python does not yet support enums or constants, skip those tests
if "enums" not in test_case[0] and "constants" not in test_case[0]:
generate_and_compare(test_case)
else:
skip(test_case)