Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | c63a41dd6ef42c834212b43e3f3bb1d0edfac6d3 (tree) |
---|---|
l'heure | 2023-10-03 05:31:51 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Refactored TstDoubles (test setup)
@@ -43,4 +43,19 @@ | ||
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | +class TstDoubles(): | |
47 | + _top = Path('TestDoubles') | |
48 | + _ref, _gen = Path('reference'), Path('_generated') | |
46 | 49 | |
50 | + def __init__(self, base_name): | |
51 | + self.base_name = Path(base_name) | |
52 | + | |
53 | + @property | |
54 | + def ref_file(self, ext='.rpy'): | |
55 | + return self._top / self._ref / self.base_name.with_suffix(ext) | |
56 | + | |
57 | + @property | |
58 | + def gen_file(self, ext='.rpy'): | |
59 | + return self._top / self._gen / self.base_name.with_suffix(ext) | |
60 | + | |
61 | + |
@@ -7,33 +7,23 @@ | ||
7 | 7 | |
8 | 8 | from TestDoubles.AIGR.protocols import Sieve |
9 | 9 | |
10 | -from . import T_Protocol | |
11 | - | |
12 | - | |
13 | - | |
10 | +from . import T_Protocol, TstDoubles | |
14 | 11 | |
15 | 12 | |
16 | 13 | def test_01_StartSieve(T_Protocol): |
17 | - ref_file = 'TestDoubles/reference/protocols/StartSieve.rpy' | |
18 | - gen_file = 'Testdoubles/_generated/protocols/StartSieve.rpy' | |
19 | - | |
14 | + td = TstDoubles('protocols/StartSieve') | |
20 | 15 | out = T_Protocol.render(protocols=[Sieve.StartSieve,]) |
21 | - with open(gen_file, 'w') as f: | |
16 | + with open(td.gen_file, 'w') as f: | |
22 | 17 | f.write(out) |
23 | - logger.debug(f"Comparing the generated file ({gen_file}) and the reference ({ref_file})") | |
24 | - assert filecmp.cmp(gen_file, ref_file), f"The generated file ({gen_file}) and the reference ({ref_file}) are not the same" | |
18 | + assert filecmp.cmp(td.gen_file, td.ref_file), f"The generated file ({td.gen_file}) and the reference ({td.ref_file}) are not the same" | |
25 | 19 | |
26 | 20 | |
27 | -#@pytest.mark.skip("Need to test AIGR.protocols:: parameters first (and writer for it to)") | |
28 | 21 | def test_03_SlowStart(T_Protocol): |
29 | - ref_file = 'TestDoubles/reference/protocols/SlowStart.rpy' | |
30 | - gen_file = 'Testdoubles/_generated/protocols/SlowStart.rpy' | |
31 | - | |
22 | + td = TstDoubles('protocols/SlowStart') | |
32 | 23 | out = T_Protocol.render(protocols=[Sieve.SlowStart,]) |
33 | - with open(gen_file, 'w') as f: | |
24 | + with open(td.gen_file, 'w') as f: | |
34 | 25 | f.write(out) |
35 | - logger.debug(f"Comparing the generated file ({gen_file}) and the reference ({ref_file})") | |
36 | - assert filecmp.cmp(gen_file, ref_file), f"The generated file ({gen_file}) and the reference ({ref_file}) are not the same" | |
26 | + assert filecmp.cmp(td.gen_file, td.ref_file), f"The generated file ({td.gen_file}) and the reference ({td.ref_file}) are not the same" | |
37 | 27 | |
38 | 28 | |
39 | 29 |