Returns the latest tmpfile test directory prefix.
()
| 120 | |
| 121 | |
| 122 | def find_latest_test_dir(): |
| 123 | """Returns the latest tmpfile test directory prefix.""" |
| 124 | tmpdir = tempfile.gettempdir() |
| 125 | |
| 126 | def join_tmp(basename): |
| 127 | return os.path.join(tmpdir, basename) |
| 128 | |
| 129 | def is_valid_test_tmpdir(basename): |
| 130 | fullpath = join_tmp(basename) |
| 131 | return ( |
| 132 | os.path.isdir(fullpath) |
| 133 | and basename.startswith(TMPDIR_PREFIX) |
| 134 | and os.access(fullpath, os.R_OK) |
| 135 | ) |
| 136 | |
| 137 | testdir_paths = [ |
| 138 | join_tmp(name) for name in os.listdir(tmpdir) if is_valid_test_tmpdir(name) |
| 139 | ] |
| 140 | |
| 141 | return max(testdir_paths, key=os.path.getmtime) if testdir_paths else None |
| 142 | |
| 143 | |
| 144 | def get_log_events(source, logfile): |
no test coverage detected