@@ 71-89 (lines=19) @@ | ||
68 | } |
|
69 | ||
70 | ||
71 | @pytest.fixture |
|
72 | def tmpfile(): |
|
73 | # NOTE: instead of using a with block and delete=True we are creating and |
|
74 | # manually deleting the file, such that we can close it before running the |
|
75 | # tests. This is necessary since on Windows we can not open the same file |
|
76 | # twice, so for the FileStorageObserver to read it, we need to close it. |
|
77 | f = tempfile.NamedTemporaryFile(suffix='.py', delete=False) |
|
78 | ||
79 | f.content = 'import sacred\n' |
|
80 | f.write(f.content.encode()) |
|
81 | f.flush() |
|
82 | f.seek(0) |
|
83 | f.md5sum = hashlib.md5(f.read()).hexdigest() |
|
84 | ||
85 | f.close() |
|
86 | ||
87 | yield f |
|
88 | ||
89 | os.remove(f.name) |
|
90 | ||
91 | ||
92 | def test_sql_observer_started_event_creates_run(sql_obs, sample_run, session): |
@@ 44-62 (lines=19) @@ | ||
41 | return tmpdir, FileStorageObserver.create(tmpdir.strpath) |
|
42 | ||
43 | ||
44 | @pytest.fixture |
|
45 | def tmpfile(): |
|
46 | # NOTE: instead of using a with block and delete=True we are creating and |
|
47 | # manually deleting the file, such that we can close it before running the |
|
48 | # tests. This is necessary since on Windows we can not open the same file |
|
49 | # twice, so for the FileStorageObserver to read it, we need to close it. |
|
50 | f = tempfile.NamedTemporaryFile(suffix='.py', delete=False) |
|
51 | ||
52 | f.content = 'import sacred\n' |
|
53 | f.write(f.content.encode()) |
|
54 | f.flush() |
|
55 | f.seek(0) |
|
56 | f.md5sum = hashlib.md5(f.read()).hexdigest() |
|
57 | ||
58 | f.close() |
|
59 | ||
60 | yield f |
|
61 | ||
62 | os.remove(f.name) |
|
63 | ||
64 | ||
65 | def test_fs_observer_started_event_creates_rundir(dir_obs, sample_run): |