Call the predictable wrapper under test with a mocked file to test. Instead of d8, we use python and a python mock script. This mock script is expecting two arguments, mode (one of 'equal', 'differ' or 'missing') and a path to a temporary file for simulating non-determinism.
(mode)
| 18 | TOOLS_DIR, 'unittests', 'testdata', 'predictable_mocked.py') |
| 19 | |
| 20 | def call_wrapper(mode): |
| 21 | """Call the predictable wrapper under test with a mocked file to test. |
| 22 | |
| 23 | Instead of d8, we use python and a python mock script. This mock script is |
| 24 | expecting two arguments, mode (one of 'equal', 'differ' or 'missing') and |
| 25 | a path to a temporary file for simulating non-determinism. |
| 26 | """ |
| 27 | fd, state_file = tempfile.mkstemp() |
| 28 | os.close(fd) |
| 29 | try: |
| 30 | args = [ |
| 31 | sys.executable, |
| 32 | PREDICTABLE_WRAPPER, |
| 33 | sys.executable, |
| 34 | PREDICTABLE_MOCKED, |
| 35 | mode, |
| 36 | state_file, |
| 37 | ] |
| 38 | proc = subprocess.Popen(args, stdout=subprocess.PIPE) |
| 39 | proc.communicate() |
| 40 | return proc.returncode |
| 41 | finally: |
| 42 | os.unlink(state_file) |
| 43 | |
| 44 | |
| 45 | class PredictableTest(unittest.TestCase): |
no test coverage detected
searching dependent graphs…