You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Historically our test files have been runnable as independent Python scripts e.g. python test_pp_cf.py. We even customise the help message e.g. python test_pp_cf.py --help.
This relies on the block below, plus the inclusion of if __name__ == "__main__": tests.main() in every test file.
print("saving list of files used by tests to %s"%fname)
_EXPORT_DATAPATHS_FILE=open(fname, "w")
else:
_EXPORT_DATAPATHS_FILE=None
if"--create-missing"insys.argv:
sys.argv.remove("--create-missing")
print("Allowing creation of missing test results.")
os.environ["IRIS_TEST_CREATE_MISSING"] ="true"
defmain():
"""A wrapper for unittest.main() which adds iris.test specific options to the help (-h) output."""
if"-h"insys.argvor"--help"insys.argv:
stdout=sys.stdout
buff=io.StringIO()
# NB. unittest.main() raises an exception after it's shown the help text
try:
sys.stdout=buff
unittest.main()
finally:
sys.stdout=stdout
lines=buff.getvalue().split("\n")
lines.insert(9, "Iris-specific options:")
lines.insert(
10,
" -d Display matplotlib figures (uses tkagg).",
)
lines.insert(
11,
" NOTE: To compare results of failing tests, ",
)
lines.insert(12, " use idiff.py instead")
lines.insert(
13,
" --data-files-used Save a list of files used to a temporary file",
)
lines.insert(14, " -m Create missing test results")
print("\n".join(lines))
else:
unittest.main()
Now we are using PyTest I often do not import the tests module, and I have not bothered making my files runnable since they are intended to be run via PyTest e.g. pytest test_pp_cf.py.
I think we should remove the runnability from our tests, and if those extra command line options are important then we should explore how they can be offered via PyTest configurability instead. Happy to discuss.
The text was updated successfully, but these errors were encountered:
Historically our test files have been runnable as independent Python scripts e.g.
python test_pp_cf.py
. We even customise the help message e.g.python test_pp_cf.py --help
.This relies on the block below, plus the inclusion of
if __name__ == "__main__": tests.main()
in every test file.iris/lib/iris/tests/__init__.py
Lines 91 to 135 in c6151e8
Now we are using PyTest I often do not import the
tests
module, and I have not bothered making my files runnable since they are intended to be run via PyTest e.g.pytest test_pp_cf.py
.I think we should remove the runnability from our tests, and if those extra command line options are important then we should explore how they can be offered via PyTest configurability instead. Happy to discuss.
The text was updated successfully, but these errors were encountered: