home · contact · privacy
Avoid race condition of test databases created with same timestamp.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 14 Jun 2024 12:27:57 +0000 (14:27 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 14 Jun 2024 12:27:57 +0000 (14:27 +0200)
tests/utils.py

index 6f44f611b487f139536822b6340fae5f5ddcf5d5..6581c61a1546e952c08b2669d28efdc0e27a06ee 100644 (file)
@@ -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: