# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import pytest
try:
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)
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"
)
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")
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")
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):
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,