From: Christian Heller Date: Fri, 14 Jun 2024 12:27:57 +0000 (+0200) Subject: Avoid race condition of test databases created with same timestamp. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/ledger?a=commitdiff_plain;h=916da7ef93591d5c542dec6b64f7643a16ca0e96;p=plomtask Avoid race condition of test databases created with same timestamp. --- diff --git a/tests/utils.py b/tests/utils.py index 6f44f61..6581c61 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,7 +3,7 @@ from unittest import TestCase from threading import Thread from http.client import HTTPConnection from urllib.parse import urlencode -from datetime import datetime +from uuid import uuid4 from os import remove as remove_file from typing import Mapping, Any from plomtask.db import DatabaseFile, DatabaseConnection @@ -53,8 +53,7 @@ class TestCaseWithDB(TestCase): Process.empty_cache() ProcessStep.empty_cache() Todo.empty_cache() - timestamp = datetime.now().timestamp() - self.db_file = DatabaseFile.create_at(f'test_db:{timestamp}') + self.db_file = DatabaseFile.create_at(f'test_db:{uuid4()}') self.db_conn = DatabaseConnection(self.db_file) def tearDown(self) -> None: