Skip to content

Fix warning messages due to nose test deprecation#4322

Open
bhouse-nexthop wants to merge 1 commit intosonic-net:masterfrom
bhouse-nexthop:silence_warnings
Open

Fix warning messages due to nose test deprecation#4322
bhouse-nexthop wants to merge 1 commit intosonic-net:masterfrom
bhouse-nexthop:silence_warnings

Conversation

@bhouse-nexthop
Copy link
Contributor

What I did

Multiple warnings similar to the below are emitted during test execution:

tests/vnet_route_check_test.py::TestVnetRouteCheck::test_vnet_route_check
  /usr/lib/python3/dist-packages/_pytest/fixtures.py:901: PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
  tests/vnet_route_check_test.py::TestVnetRouteCheck::test_vnet_route_check 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

How I did it

Rename def setup(self) to def setup_method(self) and def teardown(self) to def teardown_method(self) as per documentation.

How to verify it

Observe when running unit tests these warnings are no longer output

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bhouse-nexthop
Copy link
Contributor Author

@yxieca can you review and merge this simple PR?

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bhouse-nexthop
Copy link
Contributor Author

@qiluo-msft can you please merge this very simple fix to get rid of a bunch of test noise?

@yxieca
Copy link
Contributor

yxieca commented Mar 3, 2026

AI agent on behalf of Ying: Quick review—overall change looks fine. One issue: in tests/swap_allocator_test.py the method remains @classmethod but renamed to setup_method. Pytest expects setup_method(self, method) and it should not be a classmethod. Suggest either keep @classmethod setup_class/teardown_class, or change to def setup_method(self, method): without @classmethod. Everything else looks OK.

@mssonicbld
Copy link
Collaborator

/azp run

Multiple warnings similar to the below are emitted during test execution:
```
tests/vnet_route_check_test.py::TestVnetRouteCheck::test_vnet_route_check
  /usr/lib/python3/dist-packages/_pytest/fixtures.py:901: PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.
  tests/vnet_route_check_test.py::TestVnetRouteCheck::test_vnet_route_check 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
```

Rename `def setup(self)` to `def setup_method(self)` and `def teardown(self)` to
`def teardown_method(self)` as per documentation.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bhouse-nexthop
Copy link
Contributor Author

you're right, I missed that in my sed, switched from setup_method to setup_class for that one function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants