mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-02 05:20:33 -05:00
Simplify skipping tests depending on json-c
All tests in bin/tests/system/statschannel/tests-json.py require json-c
support to be enabled in BIND 9 at build-time. Instead of applying the
same pytest.mark.skipif() decorator to every test in that file, set the
'pytestmark' global accordingly in order to immediately skip all tests
in tests-json.py if json-c support is not compiled in.
Remove all occurrences of the @pytest.mark.json decorator (and all
associated code) from the "statschannel" system test as the json module
is a part of the Python standard library since Python 2.6 (so checking
whether it is available is redundant) and checking for json-c support in
the tested BIND 9 build is already handled by setting the 'pytestmark'
global accordingly.
Also remove a related excerpt from bin/tests/system/rpzextra/conftest.py
as it is a copy-paste artifact that serves no purpose in the "rpzextra"
system test.
(cherry picked from commit 0a76f186a5)
This commit is contained in:
parent
f37e0f2cbe
commit
3680763577
3 changed files with 3 additions and 38 deletions
|
|
@ -9,7 +9,6 @@
|
|||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
try:
|
||||
|
|
@ -34,9 +33,3 @@ def pytest_collection_modifyitems(config, items):
|
|||
for item in items:
|
||||
if "dnspython" in item.keywords:
|
||||
item.add_marker(skip_requests)
|
||||
# Test if JSON statistics channel was enabled
|
||||
no_jsonstats = pytest.mark.skip(reason="need JSON statistics to be enabled")
|
||||
if os.getenv("HAVEJSONSTATS") is None:
|
||||
for item in items:
|
||||
if "json" in item.keywords:
|
||||
item.add_marker(no_jsonstats)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ def pytest_configure(config):
|
|||
config.addinivalue_line(
|
||||
"markers", "requests: mark tests that need requests to function"
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers", "json: mark tests that need json to function"
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers", "xml: mark tests that need xml.etree to function"
|
||||
)
|
||||
|
|
@ -37,15 +34,6 @@ def pytest_collection_modifyitems(config, items):
|
|||
for item in items:
|
||||
if "requests" in item.keywords:
|
||||
item.add_marker(skip_requests)
|
||||
# Test for json module
|
||||
skip_json = pytest.mark.skip(
|
||||
reason="need json module to run")
|
||||
try:
|
||||
import json # noqa: F401
|
||||
except ModuleNotFoundError:
|
||||
for item in items:
|
||||
if "json" in item.keywords:
|
||||
item.add_marker(skip_json)
|
||||
# Test for xml module
|
||||
skip_xml = pytest.mark.skip(
|
||||
reason="need xml module to run")
|
||||
|
|
@ -55,13 +43,6 @@ def pytest_collection_modifyitems(config, items):
|
|||
for item in items:
|
||||
if "xml" in item.keywords:
|
||||
item.add_marker(skip_xml)
|
||||
# Test if JSON statistics channel was enabled
|
||||
no_jsonstats = pytest.mark.skip(
|
||||
reason="need JSON statistics to be enabled")
|
||||
if os.getenv("HAVEJSONSTATS") is None:
|
||||
for item in items:
|
||||
if "json" in item.keywords:
|
||||
item.add_marker(no_jsonstats)
|
||||
# Test if XML statistics channel was enabled
|
||||
no_xmlstats = pytest.mark.skip(
|
||||
reason="need XML statistics to be enabled")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import requests
|
|||
|
||||
import generic
|
||||
|
||||
pytestmark = pytest.mark.skipif(not os.environ.get('HAVEJSONSTATS'),
|
||||
reason='json-c support disabled in the build')
|
||||
|
||||
|
||||
# JSON helper functions
|
||||
def fetch_zones_json(statsip, statsport):
|
||||
|
|
@ -72,39 +75,27 @@ def load_zone_json(zone):
|
|||
return name
|
||||
|
||||
|
||||
@pytest.mark.json
|
||||
@pytest.mark.requests
|
||||
@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1",
|
||||
reason="JSON not configured")
|
||||
def test_zone_timers_primary_json(statsport):
|
||||
generic.test_zone_timers_primary(fetch_zones_json, load_timers_json,
|
||||
statsip="10.53.0.1", statsport=statsport,
|
||||
zonedir="ns1")
|
||||
|
||||
|
||||
@pytest.mark.json
|
||||
@pytest.mark.requests
|
||||
@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1",
|
||||
reason="JSON not configured")
|
||||
def test_zone_timers_secondary_json(statsport):
|
||||
generic.test_zone_timers_secondary(fetch_zones_json, load_timers_json,
|
||||
statsip="10.53.0.3", statsport=statsport,
|
||||
zonedir="ns3")
|
||||
|
||||
|
||||
@pytest.mark.json
|
||||
@pytest.mark.requests
|
||||
@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1",
|
||||
reason="JSON not configured")
|
||||
def test_zone_with_many_keys_json(statsport):
|
||||
generic.test_zone_with_many_keys(fetch_zones_json, load_zone_json,
|
||||
statsip="10.53.0.2", statsport=statsport)
|
||||
|
||||
|
||||
@pytest.mark.json
|
||||
@pytest.mark.requests
|
||||
@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1",
|
||||
reason="JSON not configured")
|
||||
def test_traffic_json(named_port, statsport):
|
||||
generic_dnspython = pytest.importorskip('generic_dnspython')
|
||||
generic_dnspython.test_traffic(fetch_traffic_json,
|
||||
|
|
|
|||
Loading…
Reference in a new issue