Taragolis commented on PR #29035:
URL: https://github.com/apache/airflow/pull/29035#issuecomment-1396928177
Yep, check in general this actually work (except teardown fixture)
```python
import pytest
class TestNoseSetupTearDown:
def setup(self):
self.variable = 1
def teardown(self):
self.variable = 0
def test_nose_setup(self):
assert self.variable == 1
class TestFixturesUsesNoseNaming:
@pytest.fixture(autouse=True)
def setup(self):
self.variable = 1
@pytest.fixture(autouse=True)
def teardown(self):
"""This fixture will fail until it renamed"""
# No make sense to use fixture by this way, and we internally not
use it
yield
self.variable = 0
def test_pytest_fixtures(self):
assert self.variable == 1
```
But with additional warnings
```console
❯ pytest tests/test_nose.py
================================================================================
test session starts
================================================================================
platform darwin -- Python 3.9.9, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/taragolis/Projects/common/airflow-local, configfile:
pytest.ini
plugins: subtests-0.9.0, airflow-2-0.1.0, anyio-3.6.2
collected 2 items
tests/test_nose.py ..E
[100%]
======================================================================================
ERRORS
=======================================================================================
_______________________________________________________ ERROR at teardown of
TestFixturesUsesNoseNaming.test_pytest_fixtures
________________________________________________________
Fixture "teardown" called directly. Fixtures are not meant to be called
directly,
but are created automatically when test functions request them as parameters.
See https://docs.pytest.org/en/stable/explanation/fixtures.html for more
information about fixtures, and
https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly
about how to update your code.
=================================================================================
warnings summary
==================================================================================
tests/test_nose.py::TestNoseSetupTearDown::test_nose_setup
/Users/taragolis/Projects/common/airflow-local/.nox/develop/lib/python3.9/site-packages/_pytest/fixtures.py:901:
PytestRemovedIn8Warning: Support for nose tests is deprecated and will be
removed in a future release.
tests/test_nose.py::TestNoseSetupTearDown::test_nose_setup is using
nose-specific method: `setup(self)`
To remove this warning, rename it to `setup_method(self)`
See docs:
https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose
fixture_result = next(generator)
tests/test_nose.py::TestNoseSetupTearDown::test_nose_setup
/Users/taragolis/Projects/common/airflow-local/.nox/develop/lib/python3.9/site-packages/_pytest/fixtures.py:917:
PytestRemovedIn8Warning: Support for nose tests is deprecated and will be
removed in a future release.
tests/test_nose.py::TestNoseSetupTearDown::test_nose_setup is using
nose-specific method: `teardown(self)`
To remove this warning, rename it to `teardown_method(self)`
See docs:
https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose
next(it)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==============================================================================
short test summary info
==============================================================================
ERROR tests/test_nose.py::TestFixturesUsesNoseNaming::test_pytest_fixtures
====================================================================== 2
passed, 2 warnings, 1 error in 0.03s
=======================================================================
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]