config.addinivalue_line(
"markers", "requests: mark tests that need requests to function"
)
- config.addinivalue_line(
- "markers", "xml: mark tests that need xml.etree to function"
- )
def pytest_collection_modifyitems(config, items):
for item in items:
if "requests" in item.keywords:
item.add_marker(skip_requests)
- # Test for xml module
- skip_xml = pytest.mark.skip(
- reason="need xml module to run")
- try:
- import xml.etree.ElementTree # noqa: F401
- except ModuleNotFoundError:
- for item in items:
- if "xml" in item.keywords:
- item.add_marker(skip_xml)
- # Test if XML statistics channel was enabled
- no_xmlstats = pytest.mark.skip(
- reason="need XML statistics to be enabled")
- if os.getenv("HAVEXMLSTATS") is None:
- for item in items:
- if "xml" in item.keywords:
- item.add_marker(no_xmlstats)
@pytest.fixture
import generic
+pytestmark = pytest.mark.skipif(not os.environ.get('HAVEXMLSTATS'),
+ reason='libxml2 support disabled in the build')
+
# XML helper functions
def fetch_zones_xml(statsip, statsport):
return name
-@pytest.mark.xml
@pytest.mark.requests
-@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1",
- reason="XML not configured")
def test_zone_timers_primary_xml(statsport):
generic.test_zone_timers_primary(fetch_zones_xml, load_timers_xml,
statsip="10.53.0.1", statsport=statsport,
zonedir="ns1")
-@pytest.mark.xml
@pytest.mark.requests
-@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1",
- reason="XML not configured")
def test_zone_timers_secondary_xml(statsport):
generic.test_zone_timers_secondary(fetch_zones_xml, load_timers_xml,
statsip="10.53.0.3", statsport=statsport,
zonedir="ns3")
-@pytest.mark.xml
@pytest.mark.requests
-@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1",
- reason="XML not configured")
def test_zone_with_many_keys_xml(statsport):
generic.test_zone_with_many_keys(fetch_zones_xml, load_zone_xml,
statsip="10.53.0.2", statsport=statsport)
-@pytest.mark.xml
@pytest.mark.requests
-@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1",
- reason="XML not configured")
def test_traffic_xml(named_port, statsport):
generic_dnspython = pytest.importorskip('generic_dnspython')
generic_dnspython.test_traffic(fetch_traffic_xml,