Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revisión | ee2503fecb73cd85c90558e78a5f0e8b572ca7d0 (tree) |
---|---|
Tiempo | 2023-10-03 19:31:12 |
Autor | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Refactored pytst on protocol file with generatedProtocol_verifier
@@ -18,10 +18,9 @@ | ||
18 | 18 | # |
19 | 19 | rPY_CURRENT = \ |
20 | 20 | pytst/writers/RPy/test_2_ProtocolDataStructures.py \ |
21 | - | |
21 | + pytst/writers/RPy/test_99_SieveMoats.py \ | |
22 | 22 | # |
23 | 23 | CC2CPy_TODO = \ |
24 | - pytst/writers/RPy/test_99_SieveMoats.py \ | |
25 | 24 | pytst/writers/RPy/test_999.py \ |
26 | 25 | # |
27 | 26 |
@@ -8,22 +8,25 @@ | ||
8 | 8 | from TestDoubles.AIGR.protocols import Sieve |
9 | 9 | |
10 | 10 | from . import T_Protocol, TstDoubles |
11 | +from castle.writers import RPy | |
11 | 12 | |
12 | 13 | |
13 | -def test_01_StartSieve(T_Protocol): | |
14 | - td = TstDoubles('protocols/StartSieve') | |
15 | - out = T_Protocol.render(protocols=[Sieve.StartSieve,]) | |
16 | - with open(td.gen_file, 'w') as f: | |
17 | - f.write(out) | |
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" | |
14 | +@pytest.fixture | |
15 | +def generatedProtocol_verifier(): | |
16 | + def file_matcher(aigr_dummy, td): | |
17 | + template = RPy.Template("protocol.jinja2") | |
18 | + out = template.render(protocols=(aigr_dummy,)) | |
19 | + with open(td.gen_file, 'w') as f: | |
20 | + f.write(out) | |
21 | + 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" | |
22 | + return file_matcher | |
19 | 23 | |
20 | 24 | |
21 | -def test_03_SlowStart(T_Protocol): | |
22 | - td = TstDoubles('protocols/SlowStart') | |
23 | - out = T_Protocol.render(protocols=[Sieve.SlowStart,]) | |
24 | - with open(td.gen_file, 'w') as f: | |
25 | - f.write(out) | |
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" | |
25 | +def test_01_StartSieve(generatedProtocol_verifier): | |
26 | + generatedProtocol_verifier(aigr_dummy=Sieve.StartSieve, td=TstDoubles('protocols/StartSieve')) | |
27 | + | |
28 | +def test_02_SlowStart(generatedProtocol_verifier): | |
29 | + generatedProtocol_verifier(aigr_dummy=Sieve.SlowStart, td=TstDoubles('protocols/SlowStart')) | |
27 | 30 | |
28 | 31 | |
29 | 32 |