Skip to content

Commit 9d94e43

Browse files
committed
TST: fix test to work correctly outside git work directory
Fixes #695.
1 parent 2086dd3 commit 9d94e43

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
@@ -214,12 +214,13 @@ def test_long_path(sdist_long_path):
214214

215215

216216
def test_reproducible(package_pure, tmp_path):
217-
t1 = time.time()
218-
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
219-
t2 = time.time()
220-
# Ensure that the two sdists are build at least one second apart.
221-
time.sleep(max(t1 + 1.0 - t2, 0.0))
222-
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
217+
with in_git_repo_context():
218+
t1 = time.time()
219+
sdist_path_a = mesonpy.build_sdist(tmp_path / 'a')
220+
t2 = time.time()
221+
# Ensure that the two sdists are build at least one second apart.
222+
time.sleep(max(t1 + 1.0 - t2, 0.0))
223+
sdist_path_b = mesonpy.build_sdist(tmp_path / 'b')
223224

224225
assert sdist_path_a == sdist_path_b
225226
assert tmp_path.joinpath('a', sdist_path_a).read_bytes() == tmp_path.joinpath('b', sdist_path_b).read_bytes()

0 commit comments

Comments
 (0)