Mikhail Mishin
Mikhail Mishin

Reputation: 135

Pytest unittest-style setup: module setup

Pytest documentation describes four ways to setup/teardown things:

But in one project it was implemented like this:

class TestClass:
    def setup(self):
        ...
    def test_1(self):
        ...
    ...

This setup method is called around each method invocation, just like setup_method from documentation (except that it doesn't take method as an argument). But I haven't seen it in the documentation or anywhere else. Why does it work?

Upvotes: 0

Views: 490

Answers (2)

kosciej16
kosciej16

Reputation: 7158

It's part of nose testing framework which is integrated in pytest. More information you can find here

Upvotes: 0

mar
mar

Reputation: 58

Check this code https://pytest.org/latest/_modules/_pytest/python.html

I would guess it's inheriting and using

def setup(self):

Upvotes: 2

Related Questions