summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-02-24 02:11:46 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-02-24 02:12:09 +0900
commit13a48d330c4860f52a89ca910c5b4103dd710814 (patch)
tree7f50a354adc95523e2b177f97493243462457f74
parentb352927b376de69dc9e916e9aa1671c1b7fd9025 (diff)
downloadsphinx-git-13a48d330c4860f52a89ca910c5b4103dd710814.tar.gz
Fix #3438: update timestamp certainly to ensure test condition
-rwxr-xr-xtests/path.py6
-rw-r--r--tests/test_intl.py8
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/path.py b/tests/path.py
index 3c574f0c8..6af9ae105 100755
--- a/tests/path.py
+++ b/tests/path.py
@@ -123,6 +123,12 @@ class path(text_type):
"""
os.unlink(self)
+ def stat(self):
+ """
+ Returns a stat of the file.
+ """
+ return os.stat(self)
+
def utime(self, arg):
os.utime(self, arg)
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 170d22178..f8047d14f 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -500,7 +500,8 @@ def test_gettext_dont_rebuild_mo(make_app, app_params, build_mo):
assert get_number_of_update_targets(app0) == 0
# When rewriting the timestamp of mo file, the number of documents to be
# updated will be changed.
- (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
+ mtime = (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').stat().st_mtime
+ (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime((mtime + 5, mtime + 5))
assert get_number_of_update_targets(app0) == 1
# Because doctree for gettext builder can not be shared with other builders,
@@ -515,7 +516,7 @@ def test_gettext_dont_rebuild_mo(make_app, app_params, build_mo):
assert get_number_of_update_targets(app) == 0
# Even if the timestamp of the mo file is updated, the number of documents
# to be updated is 0. gettext builder does not rebuild because of mo update.
- (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
+ (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime((mtime + 10, mtime + 10))
assert get_number_of_update_targets(app) == 0
@@ -669,7 +670,8 @@ def test_html_rebuild_mo(app):
updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
assert len(updated) == 0
- (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
+ mtime = (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').stat().st_mtime
+ (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime((mtime + 5, mtime + 5))
updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
assert len(updated) == 1