|
2 | 2 | import random
|
3 | 3 | import re
|
4 | 4 | import shlex
|
| 5 | +import stat |
5 | 6 | import sys
|
6 | 7 | import sysconfig
|
7 | 8 | import time
|
@@ -160,6 +161,14 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
|
160 | 161 | self.next_single_test: TestName | None = None
|
161 | 162 | self.next_single_filename: StrPath | None = None
|
162 | 163 |
|
| 164 | + history_file = os.path.join(os.path.expanduser('~'), '.python_history') |
| 165 | + self.__history_file = history_file |
| 166 | + if os.path.exists(history_file): |
| 167 | + st = os.stat(history_file) |
| 168 | + self.__history_stat = (stat.S_IFMT(st.st_mode), st.st_size) |
| 169 | + else: |
| 170 | + self.__history_stat = None |
| 171 | + |
163 | 172 | def log(self, line: str = '') -> None:
|
164 | 173 | self.logger.log(line)
|
165 | 174 |
|
@@ -392,6 +401,16 @@ def run_test(
|
392 | 401 | else:
|
393 | 402 | result = run_single_test(test_name, runtests)
|
394 | 403 |
|
| 404 | + if self.__history_stat is None: |
| 405 | + if os.path.exists(self.__history_file): |
| 406 | + raise AssertionError(f"{test_name}: created history file") |
| 407 | + else: |
| 408 | + if not os.path.exists(self.__history_file): |
| 409 | + raise AssertionError(f"{test_name}: deleted history file") |
| 410 | + st = os.stat(self.__history_file) |
| 411 | + if self.__history_stat != (stat.S_IFMT(st.st_mode), st.st_size): |
| 412 | + raise AssertionError(f"{test_name}: altered history file") |
| 413 | + |
395 | 414 | self.results.accumulate_result(result, runtests)
|
396 | 415 |
|
397 | 416 | return result
|
|
0 commit comments