From ddd773ecb1d7631df86de9a09327c7eb003dd627 Mon Sep 17 00:00:00 2001 From: mickeypash Date: Wed, 31 Mar 2021 11:54:33 +0100 Subject: [PATCH 1/2] [docs] add table nose x pytest naming comparison --- doc/en/how-to/nose.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/en/how-to/nose.rst b/doc/en/how-to/nose.rst index a736dfa55..9ef56c6d7 100644 --- a/doc/en/how-to/nose.rst +++ b/doc/en/how-to/nose.rst @@ -70,6 +70,34 @@ Unsupported idioms / known issues fundamentally incompatible with pytest because they don't support fixtures properly since collection and test execution are separated. +Here is a table comparing the default supported naming conventions for both +nose and pytest. + +========================== ======== ====== +Convention nose pytest +========================== ======== ====== +Ⓜ test*.py ✅ +Ⓜ test_*.py ✅ ✅ +Ⓜ \*_test.py ✅ +Ⓜ \*_tests.py +Ⓒ \*\(unittest.TestCase\) ✅ ✅ +ⓜ test_\* ✅ ✅ +Ⓒ Test\* ✅ +ⓜ test_\* ✅ +ⓕ test_\* ✅ +========================== ======== ====== + +Symbols are described below + +======= ========= +Legend +======= ========= +Ⓜ module +Ⓒ Class +ⓜ method +ⓕ function +======= ========= + Migrating from nose to pytest ------------------------------ From b81003f6fbc4fe540f4e6c2c5ef13c4d52a49964 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Thu, 6 Jul 2023 00:04:15 -0700 Subject: [PATCH 2/2] Incorporate legend into main table --- doc/en/how-to/nose.rst | 43 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/doc/en/how-to/nose.rst b/doc/en/how-to/nose.rst index 9ef56c6d7..45d3357cf 100644 --- a/doc/en/how-to/nose.rst +++ b/doc/en/how-to/nose.rst @@ -47,8 +47,7 @@ Unsupported idioms / known issues - nose imports test modules with the same import path (e.g. ``tests.test_mode``) but different file system paths (e.g. ``tests/test_mode.py`` and ``other/tests/test_mode.py``) - by extending sys.path/import semantics. pytest does not do that - but there is discussion in :issue:`268` for adding some support. Note that + by extending sys.path/import semantics. pytest does not do that. Note that `nose2 choose to avoid this sys.path/import hackery `_. If you place a conftest.py file in the root directory of your project @@ -66,44 +65,34 @@ Unsupported idioms / known issues - no nose-configuration is recognized. -- ``yield``-based methods are unsupported as of pytest 4.1.0. They are +- ``yield``-based methods are fundamentally incompatible with pytest because they don't support fixtures properly since collection and test execution are separated. Here is a table comparing the default supported naming conventions for both nose and pytest. -========================== ======== ====== -Convention nose pytest -========================== ======== ====== -Ⓜ test*.py ✅ -Ⓜ test_*.py ✅ ✅ -Ⓜ \*_test.py ✅ -Ⓜ \*_tests.py -Ⓒ \*\(unittest.TestCase\) ✅ ✅ -ⓜ test_\* ✅ ✅ -Ⓒ Test\* ✅ -ⓜ test_\* ✅ -ⓕ test_\* ✅ -========================== ======== ====== +========= ========================== ======= ===== +what default naming convention pytest nose +========= ========================== ======= ===== +module ``test*.py`` ✅ +module ``test_*.py`` ✅ ✅ +module ``*_test.py`` ✅ +module ``*_tests.py`` +class ``*(unittest.TestCase)`` ✅ ✅ +method ``test_*`` ✅ ✅ +class ``Test*`` ✅ +method ``test_*`` ✅ +function ``test_*`` ✅ +========= ========================== ======= ===== -Symbols are described below - -======= ========= -Legend -======= ========= -Ⓜ module -Ⓒ Class -ⓜ method -ⓕ function -======= ========= Migrating from nose to pytest ------------------------------ `nose2pytest `_ is a Python script and pytest plugin to help convert Nose-based tests into pytest-based tests. -Specifically, the script transforms nose.tools.assert_* function calls into +Specifically, the script transforms ``nose.tools.assert_*`` function calls into raw assert statements, while preserving format of original arguments as much as possible.