The Wayback Machine - https://web.archive.org/web/20200614084106/https://github.com/pytest-dev/pytest/issues/6973
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Method teardown() is Called by pytest, even though it is not documented #6973

Open
szegel opened this issue Mar 26, 2020 · 3 comments
Open

Comments

@szegel
Copy link

@szegel szegel commented Mar 26, 2020

According to your documentation (https://docs.pytest.org/en/latest/xunit_setup.html), I can name a method teardown() in a test class, and it should not get run by pytest. I am using version pytest-3.8.2.

Pytest calls a method called teardown on class destruction even though it is specified as teardown_class in your documentation. I am guessing this accidentally did not get removed, when the names changed to teardown_class().

example:

import pytest


class TestExample:
    def teardown(self):
        print("SHOULD NOT GET RUN!!!!")

    def test_blah(self):
        print("Running example")

output:

 pytest -v -s bug_test.py 
=================================================================================================================================== test session starts ===================================================================================================================================
platform linux -- Python 3.6.9, pytest-3.8.2, py-1.7.0, pluggy-0.7.1 -- 
plugins: swte-2.0.0, mock-1.10.0
collected 1 item                                                                                                                                                                                                                                                                          

bug_test.py::TestExample::test_blah Running example
PASSEDSHOULD NOT GET RUN!!!!


====================================================================================================================================== REQUIREMENTS =======================================================================================================================================
================================================================================================================================ 1 passed in 0.03 seconds ===============
@szegel szegel changed the title Class Teardown is Called by pytest, even though it is not documented Class Method teardown() is Called by pytest, even though it is not documented Mar 26, 2020
@Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Mar 27, 2020

I assume this is part of the general mapping of camelCase to snake_case conversion that pytest's unittest integration does... so it's probably treating it like https://docs.python.org/3/library/unittest.html#unittest.TestCase.tearDown

Hopefully someone who uses this plugin can tell us what's happening!

@The-Compiler
Copy link
Member

@The-Compiler The-Compiler commented Mar 27, 2020

This is done by nose.py, probably to support the corresponding nose features. The documentation could be a bit clearer about it though, I'm guessing.

@RonnyPfannschmidt
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt commented Mar 27, 2020

would it be sensible to simply start to deprecate nose support, as far as i can tell the nose project is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.