This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-ponymail-unit-tests.git
The following commit(s) were added to refs/heads/master by this push:
new aecffce Add support for MOCK_GMTIME
aecffce is described below
commit aecffce97714289fcbbd42fddc22cf8c88fd9e00
Author: Sebb <[email protected]>
AuthorDate: Fri Aug 28 15:19:43 2020 +0100
Add support for MOCK_GMTIME
Also document PYTHONHASHSEED=0
---
README.md | 6 ++++++
tests/test-generators.py | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/README.md b/README.md
index f5d1569..97c738a 100644
--- a/README.md
+++ b/README.md
@@ -18,3 +18,9 @@ CLI args for `runall.py`:
- `--fof`: Fail if one test fails, exiting the suite
- `--load [filename]`: Only load a specific yaml test specification, don't run
all tests
+Environment variables:
+- `PYTHONHASHSEED=0`: this ensures that Sets etc return their entries in a
deterministic order
+- `MOCK_GMTIME=0`: override time.gmtime() to use the value '0' if none is
provided
+
+The above variables are useful for some tests to ensure reproducability.
+However using them may mask bugs in the code, so they should only be used
where necessary.
\ No newline at end of file
diff --git a/tests/test-generators.py b/tests/test-generators.py
index 0037f4c..bc1e4d3 100755
--- a/tests/test-generators.py
+++ b/tests/test-generators.py
@@ -148,6 +148,13 @@ def main():
tools_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'..', '..', "tools")
sys.path.append(tools_dir)
+ if os.environ.get('MOCK_GMTIME'):
+ import time
+ save_gmtime = time.gmtime
+ def _time_gmtime(secs=None):
+ return save_gmtime(secs or 0)
+ time.gmtime = _time_gmtime
+
if args.generate:
if not args.mboxfile:
sys.stderr.write("Generating a test spec requires an mbox filepath
passed with --mbox!\n")