Skip to content
Snippets Groups Projects
Commit cf8d029a authored by Matt Harbison's avatar Matt Harbison
Browse files

tests: skip doctests that use `time.tzset()` on Windows

There's no way to conditionally skip the tests for a function (see the inline
feature request).  That leaves us with the choice to either put the whole
`mercurial.utils.dateutil` module in the skip list of this script (but then this
script prints out the module as unexpectedly not tested, and misses a bunch of
tests that can be run), blacklist the test entirely (but that makes it harder to
work with on Windows), or use this hack to look for the statement that is
broken, and skip the test currently attached to one function.

(It appears that an example in the list of examples corresponds to a single
`>>>` block, and the `test` itself corresponds to a single function.  So prescan
the examples, and skip all of them when the statement is found in any, since the
setup of setting the timezone has an effect on subsequent examples.)
parent 479899e5
No related branches found
No related tags found
2 merge requests!1041Merge default into stable,!1037Workaround no `time.tzset()` on Windows in doctests
Pipeline #90801 passed
......@@ -43,7 +43,17 @@
checker = py3docchecker()
runner = doctest.DocTestRunner(checker=checker, optionflags=optionflags)
for test in finder.find(mod, name):
runner.run(test)
# Windows doesn't have time.tzset(), so skip methods that invoke it in
# a doctest, without hardcoding the function name. There is a feature
# request for adding syntax to the test itself to conditionally skip
# that would make this unnecessary:
#
# https://github.com/python/cpython/issues/117364
for example in test.examples:
if os.name == 'nt' and 'time.tzset()' in example.source:
break
else:
runner.run(test)
runner.summarize()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment