From bf5a02c9d5f8b12c386c4be3d72d230f7bfeda5f Mon Sep 17 00:00:00 2001 From: Brad Schoening Date: Sat, 8 Jul 2023 18:35:01 -0400 Subject: [PATCH 1/4] Updated to run unit test with pytest --- README-dev.rst | 13 ++++--------- test-requirements.txt | 1 + tests/unit/test_host_connection_pool.py | 3 +++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README-dev.rst b/README-dev.rst index 5c0555f3a7..fa62cad72c 100644 --- a/README-dev.rst +++ b/README-dev.rst @@ -135,11 +135,11 @@ Running Unit Tests ------------------ Unit tests can be run like so:: - nosetests -w tests/unit/ + pytest tests/unit/ You can run a specific test method like so:: - nosetests -w tests/unit/test_connection.py:ConnectionTest.test_bad_protocol_version + pytest tests/unit/test_connection.py::ConnectionTest::test_bad_protocol_version Running Integration Tests ------------------------- @@ -168,16 +168,11 @@ Seeing Test Logs in Real Time ----------------------------- Sometimes it's useful to output logs for the tests as they run:: - nosetests -w tests/unit/ --nocapture --nologcapture - -Use tee to capture logs and see them on your terminal:: - - nosetests -w tests/unit/ --nocapture --nologcapture 2>&1 | tee test.log + pytest tests/unit --log-file=test.log Testing Multiple Python Versions -------------------------------- -If you want to test all of python 2.7, 3.5, 3.6, 3.7, and pypy, use tox (this is what -TravisCI runs):: +If you want to test multiple python versions, 3.7 and 3.8, use tox (this is what TravisCI runs):: tox diff --git a/test-requirements.txt b/test-requirements.txt index 996cf4341f..f7a15b70aa 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,7 @@ -r requirements.txt scales nose +pytest mock>1.1 ccm>=2.1.2 pytz diff --git a/tests/unit/test_host_connection_pool.py b/tests/unit/test_host_connection_pool.py index 86d4bf9843..fb47e7c6af 100644 --- a/tests/unit/test_host_connection_pool.py +++ b/tests/unit/test_host_connection_pool.py @@ -24,6 +24,7 @@ from cassandra.policies import HostDistance, SimpleConvictionPolicy class _PoolTests(unittest.TestCase): + __test__ = False PoolImpl = None uses_single_connection = None @@ -205,6 +206,7 @@ def test_host_equality(self): class HostConnectionPoolTests(_PoolTests): + __test__ = True PoolImpl = HostConnectionPool uses_single_connection = False @@ -253,6 +255,7 @@ def get_conn(): class HostConnectionTests(_PoolTests): + __test__ = True PoolImpl = HostConnection uses_single_connection = True From 101629c5821501a42d397c08286885c72aee647c Mon Sep 17 00:00:00 2001 From: Brad Schoening Date: Sat, 8 Jul 2023 18:39:55 -0400 Subject: [PATCH 2/4] updated wording --- README-dev.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-dev.rst b/README-dev.rst index fa62cad72c..98f2794c2a 100644 --- a/README-dev.rst +++ b/README-dev.rst @@ -172,7 +172,7 @@ Sometimes it's useful to output logs for the tests as they run:: Testing Multiple Python Versions -------------------------------- -If you want to test multiple python versions, 3.7 and 3.8, use tox (this is what TravisCI runs):: +If you want to test multiple python versions, such as 3.7 and 3.8, use tox (this is what TravisCI runs):: tox From 2d49681f79451f6e5db3609ff3c38f8b056c0b96 Mon Sep 17 00:00:00 2001 From: Brad Schoening Date: Wed, 15 Nov 2023 16:00:00 -0500 Subject: [PATCH 3/4] Updated to document both nosetest and pytest --- README-dev.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README-dev.rst b/README-dev.rst index 98f2794c2a..eac4c5d09b 100644 --- a/README-dev.rst +++ b/README-dev.rst @@ -131,7 +131,17 @@ Then, browse to `localhost:8000 `_. Tests ===== -Running Unit Tests +Running Nose Unit Tests +------------------ +Unit tests can be run like so:: + + nosetests -w tests/unit/ + +You can run a specific test method like so:: + + nosetests -w tests/unit/test_connection.py::ConnectionTest::test_bad_protocol_version + +Running PyTest Unit Tests ------------------ Unit tests can be run like so:: @@ -168,6 +178,10 @@ Seeing Test Logs in Real Time ----------------------------- Sometimes it's useful to output logs for the tests as they run:: + nosetests -w tests/unit/ --nocapture --nologcapture + + or + pytest tests/unit --log-file=test.log Testing Multiple Python Versions From a61cadea6c432b620ed8f4cb06b6409c8409a0e5 Mon Sep 17 00:00:00 2001 From: Brad Schoening Date: Wed, 15 Nov 2023 16:02:13 -0500 Subject: [PATCH 4/4] Fix syntax error --- README-dev.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-dev.rst b/README-dev.rst index eac4c5d09b..bb529522c8 100644 --- a/README-dev.rst +++ b/README-dev.rst @@ -139,7 +139,7 @@ Unit tests can be run like so:: You can run a specific test method like so:: - nosetests -w tests/unit/test_connection.py::ConnectionTest::test_bad_protocol_version + nosetests -w tests/unit/test_connection.py:ConnectionTest.test_bad_protocol_version Running PyTest Unit Tests ------------------