Update python test framework from nose to pytest

Description

According to the homepage of nose at

Note to Users

Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should consider using Nose2py.test, or just plain unittest/unittest2.

I’ll mention that cqlsh was upgraded to pytest with the 4.1 release (CASSANDRA-17293).

Environment

None

Pull Requests

None

Activity

Brad Schoening July 7, 2023 at 1:39 AM
Edited

I’ve created a PR for updating the test_host_connection_pool class with the magic attribute __test__ = False (superclass) and __test__ = True (subclasses). This allows the test to run (and should also be backward compatible with Nose).

Unit tests now run successfully with ‘pytest tests/unit’

Bret McGuire March 22, 2023 at 9:36 PM

FTR the “NoneType is not callable” stuff is discussed more thoroughly in

Brad Schoening March 22, 2023 at 7:59 PM
Edited

You can use the skip decorator to skip tests or classes.

@pytest.mark.skip(reason="no way of currently testing this")

def test_func_one():

Or consider renaming these functions without the test_ prefix.

Elliott Russo March 20, 2023 at 2:11 PM

Current status for running tests with pytest:

8 tests fail, 7 of which are from test_host_connection_pool.py because it is trying to run functions named “test_…” and aren’t actually tests to be run. Need to bypass this superclass so pytest doesn’t try to run these.

Bret McGuire February 15, 2023 at 3:47 PM

This work will hopefully be included in the the 3.27.0 release which we’ll start working on after we “clear the decks” and get an initial new release out containing the changes that have gone into master but haven’t been included in a release yet. No guarantees but that’s certainly our hope.

 

Additional note: we’ll want to make sure pytest works correctly with every version of the Python runtime we aim to support. Note as an example, although in that case it’s nose (and I suspect that’s more of a maintenance issue than anything).

Fixed

Details

Assignee

Reporter

Fix versions

Labels

Priority

Created April 18, 2022 at 10:15 PM
Updated July 24, 2024 at 9:16 PM
Resolved July 16, 2024 at 4:45 PM