Skip to content

Commit 760013e

Browse files
Copilotmwouts
andauthored
Fix timestamp issue in test_check_source_is_newer_when_using_jupytext_sync (#1461)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mwouts <[email protected]>
1 parent 2a9162d commit 760013e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
Jupytext ChangeLog
22
==================
33

4-
1.18.0.post1 (unreleased)
4+
1.18.1 (2025-10-19)
55
-------------------
66

7+
**Fixed**
8+
- Fixed test `test_check_source_is_newer_when_using_jupytext_sync` to work reliably on systems with low filesystem timestamp resolution ([#1460](https://github.com/mwouts/jupytext/issues/1460))
9+
710
**Changed**
811
- We now use `pixi` to maintain the local Python environments used for developing and testing Jupytext.
912

src/jupytext/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Jupytext's version number"""
22

33
# Must match [N!]N(.N)*[{a|b|rc}N][.postN][.devN], cf. PEP 440
4-
__version__ = "1.18.0.post1"
4+
__version__ = "1.18.1"

tests/functional/cli/test_source_is_newer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Here we test the --check-source-is-newer option of the jupytext CLI
33
"""
44

5+
import os
56
from jupytext import cli
67
from jupytext import write
78

@@ -45,6 +46,10 @@ def test_check_source_is_newer_when_using_jupytext_sync(tmp_path, python_noteboo
4546
# Running sync on the .py file works as .py is always more recent after a --sync operation
4647
cli.jupytext([str(tmp_py), "--sync", "--check-source-is-newer"])
4748

49+
# Make .ipynb slightly older again to ensure .py is newer
50+
stat = os.stat(tmp_ipynb)
51+
os.utime(tmp_ipynb, (stat.st_atime, stat.st_mtime - 1))
52+
4853
# Now, trying to sync the .ipynb to .py raises an error because .ipynb is older than .py
4954
with pytest.raises(ValueError, match=r"Source .*notebook\.ipynb.* is older than paired file .*notebook\.py.*"):
5055
cli.jupytext([str(tmp_ipynb), "--sync", "--check-source-is-newer"])
@@ -53,6 +58,10 @@ def test_check_source_is_newer_when_using_jupytext_sync(tmp_path, python_noteboo
5358
text = tmp_ipynb.read_text().replace("A short notebook", "A short notebook with a modification")
5459
tmp_ipynb.write_text(text)
5560

61+
# Make .py slightly older to ensure .ipynb is newer
62+
stat = os.stat(tmp_py)
63+
os.utime(tmp_py, (stat.st_atime, stat.st_mtime - 1))
64+
5665
# Now, trying to sync the .py to .ipynb raises an error because the .py is older than the .ipynb
5766
with pytest.raises(ValueError, match=r"Source .*notebook\.py.* is older than paired file .*notebook\.ipynb.*"):
5867
cli.jupytext([str(tmp_py), "--sync", "--check-source-is-newer"])

0 commit comments

Comments
 (0)