Use TESTFN iso. hard-coded test file paths in sqlite3 tests · Issue #93795 · python/cpython
Current code:
| def get_db_path(): | |
| return "sqlite_testdb" | |
| class TransactionTests(unittest.TestCase): | |
| def setUp(self): | |
| try: | |
| os.remove(get_db_path()) | |
| except OSError: | |
| pass | |
| self.con1 = sqlite.connect(get_db_path(), timeout=0.1) | |
| self.cur1 = self.con1.cursor() | |
| self.con2 = sqlite.connect(get_db_path(), timeout=0.1) | |
| self.cur2 = self.con2.cursor() | |
| def tearDown(self): | |
| self.cur1.close() | |
| self.con1.close() | |
| self.cur2.close() | |
| self.con2.close() | |
| try: | |
| os.unlink(get_db_path()) | |
| except OSError: | |
| pass |
Suggesting to use the test.support helpers TESTFN and unlink.