Skip to content

Python 1297 add support for pytest for unit tests #1171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Then, browse to `localhost:8000 <http://localhost:8000>`_.
Tests
=====

Running Unit Tests
Running Nose Unit Tests
------------------
Unit tests can be run like so::

Expand All @@ -141,6 +141,16 @@ 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::

pytest tests/unit/

You can run a specific test method like so::

pytest tests/unit/test_connection.py::ConnectionTest::test_bad_protocol_version

Running Integration Tests
-------------------------
In order to run integration tests, you must specify a version to run using the ``CASSANDRA_VERSION`` or ``DSE_VERSION`` environment variable::
Expand Down Expand Up @@ -170,14 +180,14 @@ 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::
or

nosetests -w tests/unit/ --nocapture --nologcapture 2>&1 | tee test.log
pytest tests/unit --log-file=test.log

Testing Multiple Python Versions
--------------------------------
Use tox to test all of Python 3.8 through 3.12 and pypy (this is what
TravisCI runs)::

Use tox to test all of Python 3.8 through 3.12 and pypy (this is what TravisCI runs)::

tox

Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-r requirements.txt
scales
pynose
pytest
mock>1.1
ccm>=2.1.2
pytz
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_host_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from cassandra.policies import HostDistance, SimpleConvictionPolicy

class _PoolTests(unittest.TestCase):
__test__ = False
PoolImpl = None
uses_single_connection = None

Expand Down Expand Up @@ -205,6 +206,7 @@ def test_host_equality(self):


class HostConnectionPoolTests(_PoolTests):
__test__ = True
PoolImpl = HostConnectionPool
uses_single_connection = False

Expand Down Expand Up @@ -253,6 +255,7 @@ def get_conn():


class HostConnectionTests(_PoolTests):
__test__ = True
PoolImpl = HostConnection
uses_single_connection = True