forked from heremaps/flatdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dot_generator.py
More file actions
44 lines (36 loc) · 1.17 KB
/
test_dot_generator.py
File metadata and controls
44 lines (36 loc) · 1.17 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
40
41
42
43
44
'''
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.dot import DotGenerator
from .assertions import generate_and_assert_in
from .schemas import schemas_and_expectations
def test_structures_outside_of_archives_are_not_represented():
unexpected_lines = [
"_n_S"
]
generate_and_assert_in("""
namespace n{
struct S {
f : u64 : 3;
}
}
""", DotGenerator, *[], unexpected_items=unexpected_lines)
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, DotGenerator, *expectations)
def get_test_cases():
test_cases = []
for x in schemas_and_expectations(generator='dot', extension='dot'):
test_cases.append(x)
return test_cases
@pytest.mark.parametrize("case", get_test_cases())
def test_against_expectations(case):
generate_and_compare(case)