fixtures¶
wield.pytest.fixtures
pytest modules for use with wield packages and dependent software
Functions
|
Fixture that stores the output into tpath_join('capture.txt'). |
|
Fixture that stores the output into tpath_join('capture.txt'). |
|
This is a fixture providing a wrapper function for pretty printing. |
|
py.test fixture that returns the folder path of the test being run. |
|
py.test fixture that runs os.path.join(path, *arguments) to merge subpaths with the folder path of the current test being run. Useful for referring to data files. |
|
|
This fixture provides a contextmanager that causes a function to call if an AssertionError is raised. |
|
Changes the current directory to a temporary dir, and then checks if the test outputs files into it. |
|
|
Fixture that takes the value of the special test-specific folder for test run data and plots. |
|
Fixture that joins subpaths to the value of the special test-specific folder for test run data and plots. |
|
Fixture that joins subpaths to the value of the special test-specific folder for test run data and plots. |
|
Fixture that indicates that the test path should be cleared automatically before running each test. |
Prints the 10 largest memory consumers at the end of each test. |
|
Prints the 10 largest memory consumers at the end of each test. |
|
Details
- capture(request)[source][github]¶
Fixture that stores the output into tpath_join(‘capture.txt’).
This must coordinate with pytest_runtest_logreport to function. It passes required information.
- current_pytest_request(request)[source][github]¶
Fixture that stores the output into tpath_join(‘capture.txt’).
This must coordinate with pytest_runtest_logreport to function. It passes required information.
- dprint(request, tpath_join)[source][github]¶
This is a fixture providing a wrapper function for pretty printing. It uses the icecream module for pretty printing, falling back to ipythons pretty printer if needed, then to the python build in pretty printing module.
Along with printing to stdout, this function prints into the tpath_folder to save all output into output.txt.
- fpath(request)[source][github]¶
py.test fixture that returns the folder path of the test being run. Useful for accessing data files.
- fpath_join(request)[source][github]¶
py.test fixture that runs os.path.join(path, *arguments) to merge subpaths with the folder path of the current test being run. Useful for referring to data files.
- test_trigger()[source][github]¶
This fixture provides a contextmanager that causes a function to call if an AssertionError is raised. It will also call if any of its argument, or keyword arguments evaluates to True. This allows you to conveniently force calling using other flags or fixtures.
The primary usage of this is to plot outputs only on test failures, while also allowing plotting to happen using the plot fixture and pytest cmdline argument
- tmppath_assert()[source][github]¶
Changes the current directory to a temporary dir, and then checks if the test outputs files into it. If so, then the test should instead be using tpath and fpath for its file IO.
- tpath(request)[source][github]¶
Fixture that takes the value of the special test-specific folder for test run data and plots. Usually the <folder of the test>/tresults/test_name/
- tpath_join(request)[source][github]¶
Fixture that joins subpaths to the value of the special test-specific folder for test run data and plots. Usually the <folder of the test>/tresults/test_name/.
This function should be use like test_thing.save(tpath_join(‘output_file.png’))
- tpath_join_(request)[github]¶
Fixture that joins subpaths to the value of the special test-specific folder for test run data and plots. Usually the <folder of the test>/tresults/test_name/.
This function should be use like test_thing.save(tpath_join(‘output_file.png’))
- tpath_preclear(request)[source][github]¶
Fixture that indicates that the test path should be cleared automatically before running each test. This cleans up the test data.
- ws_tracemalloc()[source][github]¶
Prints the 10 largest memory consumers at the end of each test.
NOTE: this is an autouse fixture, so if it is imported, all of the tests in a module will use it. This is convenient for debugging.
It is useful for debugging memory leaks that break the test suite. Often they can come from Matplotlib.