From 916da7ef93591d5c542dec6b64f7643a16ca0e96 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 14 Jun 2024 14:27:57 +0200 Subject: [PATCH] Avoid race condition of test databases created with same timestamp. --- tests/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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: -- 2.30.2