From ef9cb2b718140e787e7257de1df5a9a2251ad610 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sun, 12 Sep 2021 02:31:44 +0200 Subject: [PATCH] Run DNS-related tests in CI --- .github/workflows/tests.yml | 7 +++++++ psycopg/tox.ini | 9 +++++++++ tests/conftest.py | 5 +++++ tests/test_dns.py | 2 ++ tests/test_dns_srv.py | 2 ++ 5 files changed, 25 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b39dd58a1..aabbf4005 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,7 @@ jobs: - {impl: c, python: 3.7, postgres: 12} - {impl: c, python: 3.8, postgres: 11} - {impl: c, python: 3.9, postgres: 10} + - {impl: dns, python: 3.9, postgres: 13} env: PSYCOPG_IMPL: ${{ matrix.impl }} @@ -49,6 +50,12 @@ jobs: # they only fail on Travis, work ok locally under tox too. PYTEST_ADDOPTS: "-m 'not subprocess'" + - name: Run DNS-related tests + run: tox -c psycopg -e dns -- --color yes -m dns + if: ${{ matrix.impl == 'dns' }} + env: + PSYCOPG_IMPL: python + services: postgresql: image: postgres:${{ matrix.postgres }} diff --git a/psycopg/tox.ini b/psycopg/tox.ini index 4ce96f6dd..e6fdacdab 100644 --- a/psycopg/tox.ini +++ b/psycopg/tox.ini @@ -11,6 +11,15 @@ extras = test deps = -e {toxinidir}/../psycopg_pool +[testenv:dns] +changedir = .. +commands = + pytest {posargs} +passenv = PG* PSYCOPG_TEST_DSN PYTEST_ADDOPTS PSYCOPG_IMPL +extras = test +deps = + dnspython + [flake8] max-line-length = 85 ignore = W503, E203 diff --git a/tests/conftest.py b/tests/conftest.py index ff2be7986..32181ceeb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,6 +30,11 @@ def pytest_configure(config): "timing: the test is timing based and can fail on cheese hardware", ) + config.addinivalue_line( + "markers", + "dns: the test requires dnspython to run", + ) + def pytest_addoption(parser): parser.addoption( diff --git a/tests/test_dns.py b/tests/test_dns.py index cf3e3e3ed..2165cc981 100644 --- a/tests/test_dns.py +++ b/tests/test_dns.py @@ -3,6 +3,8 @@ import pytest import psycopg from psycopg.conninfo import conninfo_to_dict +pytestmark = [pytest.mark.dns] + @pytest.mark.parametrize( "conninfo, want, env", diff --git a/tests/test_dns_srv.py b/tests/test_dns_srv.py index a20f2a7c8..0abb69fd9 100644 --- a/tests/test_dns_srv.py +++ b/tests/test_dns_srv.py @@ -5,6 +5,8 @@ from psycopg.conninfo import conninfo_to_dict from .test_dns import import_dnspython +pytestmark = [pytest.mark.dns] + samples_ok = [ ("", "", None), ("host=_pg._tcp.foo.com", "host=db1.example.com port=5432", None), -- 2.47.3