Skip to content

Commit

Permalink
Add more information for the test_gettext_dont_rebuild_mo test (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 22, 2023
1 parent d71c781 commit aabcda9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/test_intl.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ def test_gettext_buildr_ignores_only_directive(app):
@pytest.mark.sphinx(testroot='builder-gettext-dont-rebuild-mo')
def test_gettext_dont_rebuild_mo(make_app, app_params):
# --- don't rebuild by .mo mtime
def get_number_of_update_targets(app_):
def get_update_targets(app_):
app_.env.find_files(app_.config, app_.builder)
_, updated, _ = app_.env.get_outdated_files(config_changed=False)
return len(updated)
added, changed, removed = app_.env.get_outdated_files(config_changed=False)
return added, changed, removed

args, kwargs = app_params

Expand All @@ -633,12 +633,14 @@ def get_number_of_update_targets(app_):
time.sleep(0.01)
assert (app0.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').exists()
# Since it is after the build, the number of documents to be updated is 0
assert get_number_of_update_targets(app0) == 0
update_targets = get_update_targets(app0)
assert update_targets[1] == set(), update_targets
# When rewriting the timestamp of mo file, the number of documents to be
# updated will be changed.
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
update_targets = get_update_targets(app0)
assert update_targets[1] == {'bom'}, update_targets

# Because doctree for gettext builder can not be shared with other builders,
# erase doctreedir before gettext build.
Expand All @@ -650,11 +652,13 @@ def get_number_of_update_targets(app_):
app.build()
time.sleep(0.01)
# Since it is after the build, the number of documents to be updated is 0
assert get_number_of_update_targets(app) == 0
update_targets = get_update_targets(app)
assert update_targets[1] == set(), update_targets
# 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((mtime + 10, mtime + 10))
assert get_number_of_update_targets(app) == 0
update_targets = get_update_targets(app)
assert update_targets[1] == set(), update_targets


@sphinx_intl
Expand Down

0 comments on commit aabcda9

Please sign in to comment.