()
| 117 | |
| 118 | |
| 119 | def test_temp_dir_sentinel(): |
| 120 | from os.path import join, isdir, exists |
| 121 | |
| 122 | basedir = "test_temp_dir_sentinel" |
| 123 | fn = join(basedir, "foo", "bar") |
| 124 | if exists(basedir): |
| 125 | print("Path %s exists, not running test_temp_dir_sentinel()" % basedir) |
| 126 | return |
| 127 | os.makedirs(basedir) |
| 128 | eq_(get_closest_dir(fn)[0], basedir) |
| 129 | eq_(get_closest_dir(fn)[1], "foo") |
| 130 | sentinel = join(basedir, "foo.inuse") |
| 131 | try: |
| 132 | with temp_dir(fn, erase_after=True, with_sentinel=True): |
| 133 | assert isdir(fn) |
| 134 | assert exists(sentinel) |
| 135 | # simulate work |
| 136 | open(join(fn, "dummy.txt"), "w").close() |
| 137 | # work file should be deleted together with directory |
| 138 | assert not exists(fn) |
| 139 | assert not exists(join(basedir, "foo")) |
| 140 | # basedir should still exist, though! |
| 141 | assert isdir(basedir) |
| 142 | finally: |
| 143 | if isdir(basedir): |
| 144 | shutil.rmtree(basedir) |
| 145 | |
| 146 | |
| 147 | def test_workdir(): |
nothing calls this directly
no test coverage detected