From 4e834093c6a8aeb1f14721a2d25722566c7c0d35 Mon Sep 17 00:00:00 2001 From: Joe Lucas Date: Tue, 8 Sep 2020 09:44:22 -0400 Subject: [PATCH 1/5] Add example for __test__ --- doc/en/example/pythoncollection.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index a12e2deaa77..f2d6dc9527e 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -313,3 +313,15 @@ interpreter: collect_ignore = ["setup.py"] if sys.version_info[0] > 2: collect_ignore_glob = ["*_py2.py"] + +User modules with names matching ``test*.py`` may be discovered as tests. Since Pytest 2.6, users can prevent this test discovery by setting a boolean ``__test__`` attribute. + +.. code-block:: python + + # Will be discovered as a test + def test_class: + __test__ = True + + # Will not be discovered as a test + def test_class: + __test__ = False From 3b2ca1bcbafd9a527e84d771e09596578ffb88e8 Mon Sep 17 00:00:00 2001 From: Joe Lucas Date: Tue, 8 Sep 2020 09:46:43 -0400 Subject: [PATCH 2/5] Add to Authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index b28e5613389..01e7f994702 100644 --- a/AUTHORS +++ b/AUTHORS @@ -146,6 +146,7 @@ Jordan Guymon Jordan Moldow Jordan Speicher Joseph Hunkeler +Joseph Lucas Josh Karpel Joshua Bronson Jurko Gospodnetić From a9ac6894f6d9a3e34a2961a82415fba9785dc70a Mon Sep 17 00:00:00 2001 From: Joe Lucas Date: Tue, 8 Sep 2020 09:57:01 -0400 Subject: [PATCH 3/5] Fix Formating, Remove AUTHOR --- AUTHORS | 1 - doc/en/example/pythoncollection.rst | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 01e7f994702..b28e5613389 100644 --- a/AUTHORS +++ b/AUTHORS @@ -146,7 +146,6 @@ Jordan Guymon Jordan Moldow Jordan Speicher Joseph Hunkeler -Joseph Lucas Josh Karpel Joshua Bronson Jurko Gospodnetić diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index f2d6dc9527e..e2b10b54490 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -314,7 +314,9 @@ interpreter: if sys.version_info[0] > 2: collect_ignore_glob = ["*_py2.py"] -User modules with names matching ``test*.py`` may be discovered as tests. Since Pytest 2.6, users can prevent this test discovery by setting a boolean ``__test__`` attribute. +User modules with names matching ``test*.py`` may be discovered as tests. Since +Pytest 2.6, users can prevent this test discovery by setting a boolean +``__test__`` attribute. .. code-block:: python From 985e69738c77f0d37433a068bd99cc384f8b7e86 Mon Sep 17 00:00:00 2001 From: Joe Lucas Date: Wed, 9 Sep 2020 07:14:58 -0400 Subject: [PATCH 4/5] Shorten explanation and only cover Bool False --- doc/en/example/pythoncollection.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index e2b10b54490..39571560c7b 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -314,16 +314,11 @@ interpreter: if sys.version_info[0] > 2: collect_ignore_glob = ["*_py2.py"] -User modules with names matching ``test*.py`` may be discovered as tests. Since -Pytest 2.6, users can prevent this test discovery by setting a boolean -``__test__`` attribute. +Since Pytest 2.6, users can prevent pytest from discovering classes that start +with ``Test`` by setting a boolean ``__test__`` attribute to ``False``. .. code-block:: python - # Will be discovered as a test - def test_class: - __test__ = True - # Will not be discovered as a test - def test_class: + class TestClass: __test__ = False From a23ba6daac7c4f3685b783923c1ae7ee79885abc Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 9 Sep 2020 10:30:07 -0300 Subject: [PATCH 5/5] Fix linting --- doc/en/example/pythoncollection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 39571560c7b..c2f0348395c 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -314,7 +314,7 @@ interpreter: if sys.version_info[0] > 2: collect_ignore_glob = ["*_py2.py"] -Since Pytest 2.6, users can prevent pytest from discovering classes that start +Since Pytest 2.6, users can prevent pytest from discovering classes that start with ``Test`` by setting a boolean ``__test__`` attribute to ``False``. .. code-block:: python