| 46 | subprocess.check_call((self.pythonpath, str(dumpfile))) |
| 47 | |
| 48 | def load_and_is_true(self, expression): |
| 49 | loadfile = self.picklefile.with_name("load.py") |
| 50 | loadfile.write_text( |
| 51 | textwrap.dedent( |
| 52 | r""" |
| 53 | import pickle |
| 54 | f = open({!r}, 'rb') |
| 55 | obj = pickle.load(f) |
| 56 | f.close() |
| 57 | res = eval({!r}) |
| 58 | if not res: |
| 59 | raise SystemExit(1) |
| 60 | """.format( |
| 61 | str(self.picklefile), expression |
| 62 | ) |
| 63 | ) |
| 64 | ) |
| 65 | print(loadfile) |
| 66 | subprocess.check_call((self.pythonpath, str(loadfile))) |
| 67 | |
| 68 | |
| 69 | @pytest.mark.parametrize("obj", [42, {}, {1: 3}]) |