Skip to content

Commit

Permalink
added sleep to various tests to ensure file mtimes are different
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 25, 2023
1 parent 32b91ba commit d8a7f70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pydra/engine/tests/test_node_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import attr
import numpy as np
import pytest
import time

from .utils import (
fun_addtwo,
Expand Down Expand Up @@ -320,6 +321,7 @@ def test_task_init_7(tmp_path):
output_dir1 = nn1.output_dir

# changing the content of the file
time.sleep(2) # need the mtime to be different
file2 = tmp_path / "file2.txt"
with open(file2, "w") as f:
f.write("from pydra")
Expand Down
2 changes: 2 additions & 0 deletions pydra/engine/tests/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import attrs
from copy import deepcopy
import time

from ..specs import (
BaseSpec,
Expand Down Expand Up @@ -319,6 +320,7 @@ def test_input_file_hash_4(tmp_path):
assert hash1 == hash2

# checking if different content (the same name) affects the hash
time.sleep(2) # need the mtime to be different
file_diffcontent = tmp_path / "in_file_1.txt"
with open(file_diffcontent, "w") as f:
f.write("hi")
Expand Down
2 changes: 2 additions & 0 deletions pydra/utils/tests/test_hash.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
from hashlib import blake2b
from pathlib import Path
import time

import attrs
import pytest
Expand Down Expand Up @@ -318,6 +319,7 @@ def test_persistent_hash_cache(tmp_path):
assert hash_object(text_file, persistent_cache=cache_path) == modified_hash

# Test that changes to the text file result in new hash
time.sleep(2) # Need to ensure that the mtimes will be different
text_file_path.write_text("bar")
assert hash_object(text_file, persistent_cache=cache_path) != modified_hash
assert len(list(cache_path.iterdir())) == 2

0 comments on commit d8a7f70

Please sign in to comment.