|
4 | 4 |
|
5 | 5 | # flake8: noqa
|
6 | 6 |
|
7 |
| -import pathlib |
8 | 7 | import dts_utils
|
9 | 8 | import dts_utils.filters
|
10 | 9 |
|
11 | 10 |
|
12 |
| -def _get_dtsload() -> dts_utils.Dts: |
13 |
| - return dts_utils.Dts(pathlib.Path(__file__).parent.absolute() / "dts/sample.dts") |
14 |
| - |
15 |
| - |
16 |
| -def test_filter_enabled(): |
17 |
| - dts = _get_dtsload() |
18 |
| - pinctrl_list = dts_utils.filters.f_peripherals(dts.soc.pinctrl) |
| 11 | +def test_filter_enabled(dts_file): |
| 12 | + pinctrl_list = dts_utils.filters.f_peripherals(dts_file.dts.soc.pinctrl) |
19 | 13 | enabled_gpios = dts_utils.filters.f_enabled(pinctrl_list)
|
20 | 14 | assert len(enabled_gpios) == 7
|
21 | 15 |
|
22 | 16 |
|
23 |
| -def test_filter_enabled_exceptions(): |
24 |
| - dts = _get_dtsload() |
| 17 | +def test_filter_enabled_exceptions(dts_file): |
25 | 18 | try:
|
26 |
| - enabled_gpios = dts_utils.filters.f_enabled(dts) |
| 19 | + enabled_gpios = dts_utils.filters.f_enabled(dts_file.dts) |
27 | 20 | assert False
|
28 | 21 | except dts_utils.exceptions.InvalidTemplateValueType:
|
29 | 22 | assert True
|
30 | 23 |
|
31 | 24 |
|
32 |
| -def test_filter_owner(): |
33 |
| - dts = _get_dtsload() |
34 |
| - i2c1 = dts.i2c1 |
| 25 | +def test_filter_owner(dts_file): |
| 26 | + i2c1 = dts_file.dts.i2c1 |
35 | 27 | assert dts_utils.filters.f_owner(i2c1) == 0xBABE
|
36 | 28 |
|
37 | 29 |
|
38 |
| -def test_filter_owner_exceptions(): |
39 |
| - dts = _get_dtsload() |
| 30 | +def test_filter_owner_exceptions(dts_file): |
40 | 31 | try:
|
41 |
| - enabled_gpios = dts_utils.filters.f_owner(dts) |
| 32 | + enabled_gpios = dts_utils.filters.f_owner(dts_file.dts) |
42 | 33 | assert False
|
43 | 34 | except dts_utils.exceptions.InvalidTemplateValueType:
|
44 | 35 | assert True
|
45 | 36 |
|
46 | 37 |
|
47 |
| -def test_filter_has_property(): |
48 |
| - dts = _get_dtsload() |
49 |
| - i2c1 = dts.i2c1 |
| 38 | +def test_filter_has_property(dts_file): |
| 39 | + i2c1 = dts_file.dts.i2c1 |
50 | 40 | assert dts_utils.filters.f_has_property(i2c1, "outpost,owner")
|
51 | 41 |
|
52 | 42 |
|
53 |
| -def test_filter_has_property_exception(): |
54 |
| - dts = _get_dtsload() |
| 43 | +def test_filter_has_property_exception(dts_file): |
55 | 44 | try:
|
56 |
| - dts_utils.filters.f_has_property(dts, "outpost,owner") |
| 45 | + dts_utils.filters.f_has_property(dts_file.dts, "outpost,owner") |
57 | 46 | assert False
|
58 | 47 | except dts_utils.exceptions.InvalidTemplateValueType:
|
59 | 48 | assert True
|
60 | 49 |
|
61 | 50 |
|
62 |
| -def test_filter_with_property(): |
63 |
| - dts = _get_dtsload() |
64 |
| - dev_list = dts_utils.filters.f_peripherals(dts.root) |
| 51 | +def test_filter_with_property(dts_file): |
| 52 | + dev_list = dts_utils.filters.f_peripherals(dts_file.dts.root) |
65 | 53 | assert len(dts_utils.filters.f_with_property(dev_list, "outpost,owner")) == 1
|
66 | 54 |
|
67 | 55 |
|
68 |
| -def test_filter_with_property_exception(): |
69 |
| - dts = _get_dtsload() |
| 56 | +def test_filter_with_property_exception(dts_file): |
70 | 57 | try:
|
71 |
| - dts_utils.filters.f_with_property(dts, "outpost,owner") |
| 58 | + dts_utils.filters.f_with_property(dts_file.dts, "outpost,owner") |
72 | 59 | assert False
|
73 | 60 | except dts_utils.exceptions.InvalidTemplateValueType:
|
74 | 61 | assert True
|
75 | 62 | try:
|
76 |
| - dts_utils.filters.f_with_property(dts.usart1, "outpost,owner") |
| 63 | + dts_utils.filters.f_with_property(dts_file.dts.usart1, "outpost,owner") |
77 | 64 | assert False
|
78 | 65 | except dts_utils.exceptions.InvalidTemplateValueType:
|
79 | 66 | assert True
|
0 commit comments