Skip to content

Warnings with pytest are fixed #223

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

Merged
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
Warnings with pytest are fixed
1) [pytest.ini] testpaths has another format. It is a spaces separated list.

pytest warning:
PytestConfigWarning: No files were found in testpaths; consider removing or adjusting your testpaths configuration. Searching recursively from the current directory instead.

2) pytest tries to find the test function in TestgresException class. Let's rename it to avoid this problem.

pytest warning:
PytestCollectionWarning: cannot collect test class 'TestgresException' because it has a __init__ constructor (from: tests/test_simple.py)
    class TestgresException(Exception):

Of course, we can add __test__=False in TestgresException but it is not a good solution.
  • Loading branch information
dmitry-lipetsk committed Mar 18, 2025
commit 7d2f09486e84f38a4fc688e253b6fb633666f362
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
testpaths = ["./tests", "./testgres/plugins/pg_probackup2/pg_probackup2/tests"]
testpaths = tests testgres/plugins/pg_probackup2/pg_probackup2/tests
addopts = --strict-markers
markers =
#log_file = logs/pytest.log
Expand Down
14 changes: 9 additions & 5 deletions tests/test_testgres_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
from ..testgres import ProcessType
from ..testgres import NodeStatus
from ..testgres import IsolationLevel
from ..testgres import TestgresException

# New name prevents to collect test-functions in TestgresException and fixes
# the problem with pytest warning.
from ..testgres import TestgresException as testgres_TestgresException

from ..testgres import InitNodeException
from ..testgres import StartNodeException
from ..testgres import QueryException
Expand Down Expand Up @@ -336,7 +340,7 @@ def LOCAL__check_auxiliary_pids__multiple_attempts(
with __class__.helper__get_node(os_ops).init().start() as master:

# master node doesn't have a source walsender!
with pytest.raises(expected_exception=TestgresException):
with pytest.raises(expected_exception=testgres_TestgresException):
master.source_walsender

with master.connect() as con:
Expand Down Expand Up @@ -366,7 +370,7 @@ def LOCAL__check_auxiliary_pids__multiple_attempts(
replica.stop()

# there should be no walsender after we've stopped replica
with pytest.raises(expected_exception=TestgresException):
with pytest.raises(expected_exception=testgres_TestgresException):
replica.source_walsender

def test_exceptions(self):
Expand Down Expand Up @@ -1013,7 +1017,7 @@ def test_replication_slots(self, os_ops: OsOperations):
replica.execute('select 1')

# cannot create new slot with the same name
with pytest.raises(expected_exception=TestgresException):
with pytest.raises(expected_exception=testgres_TestgresException):
node.replicate(slot='slot1')

def test_incorrect_catchup(self, os_ops: OsOperations):
Expand All @@ -1022,7 +1026,7 @@ def test_incorrect_catchup(self, os_ops: OsOperations):
node.init(allow_streaming=True).start()

# node has no master, can't catch up
with pytest.raises(expected_exception=TestgresException):
with pytest.raises(expected_exception=testgres_TestgresException):
node.catchup()

def test_promotion(self, os_ops: OsOperations):
Expand Down