From 2b762337bdf6d1f6152d33108600a29cef07d3a4 Mon Sep 17 00:00:00 2001 From: Harry Percival Date: Tue, 25 Sep 2018 06:49:50 +0100 Subject: [PATCH 1/5] add documentation of register_assert_rewrite wip --- doc/en/assert.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index e0e9b9305..76cd66e41 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -264,8 +264,12 @@ Advanced assertion introspection Reporting details about a failing assertion is achieved by rewriting assert statements before they are run. Rewritten assert statements put introspection information into the assertion failure message. ``pytest`` only rewrites test -modules directly discovered by its test collection process, so asserts in -supporting modules which are not themselves test modules will not be rewritten. +modules directly discovered by its test collection process, so **asserts in +supporting modules which are not themselves test modules will not be rewritten**. + +You can manually enable assertion rewriting for an imported module by calling +`register_assert_rewrite` +before you import it. .. note:: From 97748b66057dd9ec34b28abe557a453fdfbfb685 Mon Sep 17 00:00:00 2001 From: Harry Percival Date: Tue, 25 Sep 2018 06:55:28 +0100 Subject: [PATCH 2/5] mention conftest.py as a good place to do it. --- doc/en/assert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 76cd66e41..1fc5917d6 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -269,7 +269,7 @@ supporting modules which are not themselves test modules will not be rewritten** You can manually enable assertion rewriting for an imported module by calling `register_assert_rewrite` -before you import it. +before you import it (a good place to do that is in ``conftest.py``). .. note:: From 11442f2ad7a9619645322704213f225b335e4114 Mon Sep 17 00:00:00 2001 From: Harry Percival Date: Tue, 25 Sep 2018 06:57:33 +0100 Subject: [PATCH 3/5] fix rst syntax thing --- doc/en/assert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 1fc5917d6..ff11be21a 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -268,7 +268,7 @@ modules directly discovered by its test collection process, so **asserts in supporting modules which are not themselves test modules will not be rewritten**. You can manually enable assertion rewriting for an imported module by calling -`register_assert_rewrite` +`register_assert_rewrite`_ before you import it (a good place to do that is in ``conftest.py``). .. note:: From 19ec300b2a05ccce0346417f1252040306ed7451 Mon Sep 17 00:00:00 2001 From: Harry Percival Date: Tue, 25 Sep 2018 06:58:47 +0100 Subject: [PATCH 4/5] fix rst syntax again --- doc/en/assert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index ff11be21a..60edbf2a3 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -268,7 +268,7 @@ modules directly discovered by its test collection process, so **asserts in supporting modules which are not themselves test modules will not be rewritten**. You can manually enable assertion rewriting for an imported module by calling -`register_assert_rewrite`_ +`register_assert_rewrite `_ before you import it (a good place to do that is in ``conftest.py``). .. note:: From b03bad5dbbddd851d0a164da56efe4d870a085bb Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 25 Sep 2018 08:12:55 -0300 Subject: [PATCH 5/5] Fix linting --- doc/en/assert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 60edbf2a3..d3deeb503 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -267,7 +267,7 @@ information into the assertion failure message. ``pytest`` only rewrites test modules directly discovered by its test collection process, so **asserts in supporting modules which are not themselves test modules will not be rewritten**. -You can manually enable assertion rewriting for an imported module by calling +You can manually enable assertion rewriting for an imported module by calling `register_assert_rewrite `_ before you import it (a good place to do that is in ``conftest.py``).