From 4285325cb88d90ad36724de9d441e51da614f249 Mon Sep 17 00:00:00 2001 From: Brian Maissy Date: Thu, 25 Jan 2018 23:07:34 +0200 Subject: [PATCH] Added note that calling pytest.main multiple times from the same process is not recommended because of import caching --- changelog/3143.doc | 1 + doc/en/usage.rst | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog/3143.doc diff --git a/changelog/3143.doc b/changelog/3143.doc new file mode 100644 index 000000000..b454708ad --- /dev/null +++ b/changelog/3143.doc @@ -0,0 +1 @@ +Added note that calling pytest.main multiple times from the same process is not recommended because of import caching. \ No newline at end of file diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 6091db8be..18830792b 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -387,6 +387,15 @@ hook was invoked:: $ python myinvoke.py *** test run reporting finishing - + +.. note:: + + Calling ``pytest.main()`` will result in importing your tests and any modules + that they import. Due to the caching mechanism of python's import system, + making subsequent calls to ``pytest.main()`` from the same process will not + reflect changes to those files between the calls. For this reason, making + multiple calls to ``pytest.main()`` from the same process (in order to re-run + tests, for example) is not recommended. + .. include:: links.inc