Skip to content

Commit 3257da4

Browse files
committed
TST: fix test to work correctly outside git work directory
Fixes #695.
1 parent 01df256 commit 3257da4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/test_sdist.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,13 @@ def test_long_path(sdist_long_path):
218218

219219

220220
def test_reproducible(package_pure, tmp_path):
221-
t1 = time.time()
222-
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
223-
t2 = time.time()
224-
# Ensure that the two sdists are build at least one second apart.
225-
time.sleep(max(t1 + 1.0 - t2, 0.0))
226-
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
221+
with in_git_repo_context():
222+
t1 = time.time()
223+
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
224+
t2 = time.time()
225+
# Ensure that the two sdists are build at least one second apart.
226+
time.sleep(max(t1 + 1.0 - t2, 0.0))
227+
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
227228

228229
assert sdist_path_a == sdist_path_b
229230
assert tmp_path.joinpath('a', sdist_path_a).read_bytes() == tmp_path.joinpath('b', sdist_path_b).read_bytes()

0 commit comments

Comments
 (0)