URL: https://github.com/freeipa/freeipa/pull/3783 Author: stanislavlevin Title: #3783: Migrate xunit-style setups to fixtures Action: opened
PR body: """ This converts `setup*`/`teardown*` functions/methods to the powerfull pytest fixtures:
``` The purpose of test fixtures is to provide a fixed baseline upon which tests can reliably and repeatedly execute. pytest fixtures offer dramatic improvements over the classic xUnit style of setup/teardown functions:
- fixtures have explicit names and are activated by declaring their use from test functions, modules, classes or whole projects.
- fixtures are implemented in a modular manner, as each fixture name triggers a fixture function which can itself use other fixtures.
- fixture management scales from simple unit to complex functional testing, allowing to parametrize fixtures and tests according to configuration and component options, or to re-use fixtures across function, class, module or whole test session scopes. ```
One of the transition patterns is as follows:
```diff class TestFooBar(XMLRPC_test): - @classmethod - def setup_class(cls): - super(TestFooBar, cls).setup_class() + @pytest.fixture(autouse=True, scope="class") + def foo_bar_setup(self, request, xmlrpc_setup): + cls = request.cls cls.beforemethod()
- @classmethod - def teardown_class(cls): - cls.aftermethod() - super(TestFooBar, cls).teardown_class() + def fin(): + cls.aftermethod() + request.addfinalizer(fin) ```
To achieve predictable results for initialization and destroy of Pytest fixtures, ones have to employ the fixtures' interdependencies.
This is the first part of the work to remove the mixing of test idioms in the IPA test suite.
Related: https://pagure.io/freeipa/issue/7989
"""
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/3783/head:pr3783 git checkout pr3783
URL: https://github.com/freeipa/freeipa/pull/3783 Author: stanislavlevin Title: #3783: Migrate xunit/unittest/nose tests to Pytest Action: closed
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/3783/head:pr3783 git checkout pr3783
freeipa-devel@lists.fedorahosted.org