From 299ec97a59ea6b2ad2951c61c695b811c0c071dc Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Wed, 22 Nov 2023 15:34:43 +0000 Subject: [PATCH] tests/i: add note about module-scoped fixtures --- tests/integration/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/integration/README.md b/tests/integration/README.md index 71bd6bfb922..e7246a53ca6 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -64,3 +64,21 @@ These methods both shut down the workflow / clean up after themselves. It is necessary to shut down workflows correctly to clean up resorces and running tasks. + +## Module Scoped Fixtures + +There's a reasonable overhead to some text fixtures, especially the ones which +involve writing files to disk or starting Cylc schedulers. + +To make tests run faster you can use module-scoped fixtures, these are test +fixtures which are created once, then reused for all tests in the module. + +You'll find a bunch of module-scoped fixtues prefixed with `mod_`, e.g. +`mod_start` is the module-scoped version of `start`. When using module-scoped +fixtures, ensure that tests do not modify the fixture object as this will enable +tests to interact. + +In order to get speedup from module-scoped fixtures when running with +pytest-xdist, we configure pytest-xdist to run all of the tests in a module in +series using the same pytest runner. This incentivises breaking up larger test +modules.