From: Vincent Bernat Date: Sun, 15 Sep 2019 17:19:06 +0000 (+0200) Subject: tests: don't use pytest.config X-Git-Tag: 1.0.5~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6bbc43b20850bb2a5ba93251e47563e3bef8d10;p=thirdparty%2Flldpd.git tests: don't use pytest.config It's deprecated in 5.0. --- diff --git a/tests/integration/test_custom.py b/tests/integration/test_custom.py index 54a05ae3..a2d6dc79 100644 --- a/tests/integration/test_custom.py +++ b/tests/integration/test_custom.py @@ -3,7 +3,7 @@ import shlex import time -@pytest.mark.skipif('Custom TLV' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Custom TLV' not in config.lldpd.features", reason="Custom TLV not supported") @pytest.mark.parametrize("commands, expected", [ (["oui 33,44,55 subtype 44"], diff --git a/tests/integration/test_dot1.py b/tests/integration/test_dot1.py index 79f120fa..ba16baa4 100644 --- a/tests/integration/test_dot1.py +++ b/tests/integration/test_dot1.py @@ -1,7 +1,7 @@ import pytest -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") class TestLldpDot1(object): diff --git a/tests/integration/test_dot3.py b/tests/integration/test_dot3.py index 6f311953..1eb5ee46 100644 --- a/tests/integration/test_dot3.py +++ b/tests/integration/test_dot3.py @@ -3,7 +3,7 @@ import shlex import time -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") class TestLldpDot3(object): diff --git a/tests/integration/test_interfaces.py b/tests/integration/test_interfaces.py index 22cb0792..77fece6d 100644 --- a/tests/integration/test_interfaces.py +++ b/tests/integration/test_interfaces.py @@ -37,7 +37,7 @@ def test_remove_bridge(lldpd, lldpcli, namespaces, links): assert out['lldp.eth0.port.descr'] == 'eth1' -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") @pytest.mark.parametrize('when', ['before', 'after']) def test_bridge_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): @@ -62,7 +62,7 @@ def test_bridge_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): ['100', '200', '300'] -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") @pytest.mark.parametrize('when', ['before', 'after']) def test_bond(lldpd1, lldpd, lldpcli, namespaces, links, when): @@ -87,7 +87,7 @@ def test_bond(lldpd1, lldpd, lldpcli, namespaces, links, when): assert out['lldp.eth0.port.mac'] == '00:00:00:00:00:02' -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") @pytest.mark.parametrize('when', ['before', 'after']) def test_team(lldpd1, lldpd, lldpcli, namespaces, links, when): @@ -109,9 +109,9 @@ def test_team(lldpd1, lldpd, lldpcli, namespaces, links, when): assert out['lldp.eth0.port.mac'] == '00:00:00:00:00:02' -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") @pytest.mark.parametrize('when', ['before', 'after']) def test_bond_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): @@ -137,7 +137,7 @@ def test_bond_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): ['300', '301', '302', '303'] -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") @pytest.mark.parametrize('when', ['before', 'after']) def test_just_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): @@ -157,7 +157,7 @@ def test_just_vlan(lldpd1, lldpd, lldpcli, namespaces, links, when): assert out['lldp.eth0.vlan.vlan-id'] == ['300', '400'] -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") @pytest.mark.parametrize('kind', ['plain', 'bridge', 'bond']) def test_remove_vlan(lldpd1, lldpd, lldpcli, namespaces, links, kind): @@ -184,7 +184,7 @@ def test_remove_vlan(lldpd1, lldpd, lldpcli, namespaces, links, kind): assert out['lldp.eth0.vlan.vlan-id'] == ['400', '500'] -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_unenslave_bond(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): @@ -199,7 +199,7 @@ def test_unenslave_bond(lldpd1, lldpd, lldpcli, namespaces, links): assert 'lldp.eth0.port.aggregation' not in out -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") def test_unenslave_bond_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): @@ -232,7 +232,7 @@ def test_down_then_up(lldpd1, lldpd, lldpcli, namespaces, links): assert out['lldp.eth0.port.descr'] == 'eth1' -@pytest.mark.skipif('Dot1' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot1' not in config.lldpd.features", reason="Dot1 not supported") def test_down_then_up_with_vlan(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): diff --git a/tests/integration/test_lldpcli.py b/tests/integration/test_lldpcli.py index 8949d6f6..04c58a11 100644 --- a/tests/integration/test_lldpcli.py +++ b/tests/integration/test_lldpcli.py @@ -58,8 +58,8 @@ Interface: eth0, via: unknown, Time: {time} TTL: 120 ------------------------------------------------------------------------------- """)], ids=["neighbors", "interfaces"]) -def test_text_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, - expected): +def test_text_output(request, lldpd1, lldpd, lldpcli, namespaces, uname, + command, expected): with namespaces(2): lldpd() with namespaces(1): @@ -68,7 +68,7 @@ def test_text_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, assert result.returncode == 0 out = result.stdout.decode('ascii') - if 'Dot3' in pytest.config.lldpd.features: + if 'Dot3' in request.config.lldpd.features: dot3 = """ PMD autoneg: supported: no, enabled: no MAU oper type: 10GigBaseCX4 - X copper over 8 pair 100-Ohm balanced cable""" @@ -96,7 +96,7 @@ def test_text_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, uname=uname, dot3=dot3) -@pytest.mark.skipif('JSON' not in pytest.config.lldpcli.outputs, +@pytest.mark.skipif("'JSON' not in config.lldpcli.outputs", reason="JSON not supported") @pytest.mark.parametrize("command, expected", [ ("neighbors", @@ -145,8 +145,8 @@ def test_text_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, "descr": "eth0"}, "ttl": { "ttl": "120"}}}}})], ids=["neighbors", "interfaces"]) -def test_json_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, - expected): +def test_json_output(request, lldpd1, lldpd, lldpcli, namespaces, uname, + command, expected): with namespaces(2): lldpd() with namespaces(1): @@ -165,7 +165,7 @@ def test_json_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, descr = "Spectacular GNU/Linux 2016 {}".format(uname) expected['lldp']['interface']['eth0']['chassis'][name]["descr"] = descr - if 'Dot3' in pytest.config.lldpd.features: + if 'Dot3' in request.config.lldpd.features: expected['lldp']['interface']['eth0']['port']['auto-negotiation'] = { "enabled": False, "supported": False, @@ -174,7 +174,7 @@ def test_json_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, assert j == expected -@pytest.mark.skipif('JSON' not in pytest.config.lldpcli.outputs, +@pytest.mark.skipif("'JSON' not in config.lldpcli.outputs", reason="JSON not supported") @pytest.mark.parametrize("command, expected", [ ("neighbors", @@ -236,8 +236,8 @@ def test_json_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, "ttl": [{"ttl": "120"}] }]} ]})], ids=["neighbors", "interfaces"]) -def test_json0_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, - expected): +def test_json0_output(request, lldpd1, lldpd, lldpcli, namespaces, uname, + command, expected): with namespaces(2): lldpd() with namespaces(1): @@ -255,7 +255,7 @@ def test_json0_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, descr = "Spectacular GNU/Linux 2016 {}".format(uname) expected['lldp'][0]['interface'][0]['chassis'][0]["descr"][0]['value'] = descr - if 'Dot3' in pytest.config.lldpd.features: + if 'Dot3' in request.config.lldpd.features: expected['lldp'][0]['interface'][0]['port'][0]['auto-negotiation'] = [{ "enabled": False, "supported": False, @@ -265,7 +265,7 @@ def test_json0_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, assert j == expected -@pytest.mark.skipif('XML' not in pytest.config.lldpcli.outputs, +@pytest.mark.skipif("'XML' not in config.lldpcli.outputs", reason="XML not supported") @pytest.mark.parametrize("command, expected", [ ("neighbors", @@ -314,8 +314,8 @@ def test_json0_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, """)], ids=["neighbors", "interfaces"]) -def test_xml_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, - expected): +def test_xml_output(request, lldpd1, lldpd, lldpcli, namespaces, uname, + command, expected): with namespaces(2): lldpd() with namespaces(1): @@ -330,7 +330,7 @@ def test_xml_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, "capability[@type='Router']")[0].attrib['enabled'] station = xml.findall("./interface[1]/chassis/" "capability[@type='Station']")[0].attrib['enabled'] - if 'Dot3' in pytest.config.lldpd.features: + if 'Dot3' in request.config.lldpd.features: dot3 = """ 10GigBaseCX4 - X copper over 8 pair 100-Ohm balanced cable @@ -345,7 +345,7 @@ def test_xml_output(lldpd1, lldpd, lldpcli, namespaces, uname, command, assert ET.tostring(xml) == ET.tostring(expected) -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_configure_one_port(lldpd1, lldpd, lldpcli, namespaces, links): links(namespaces(1), namespaces(2)) @@ -367,7 +367,7 @@ def test_configure_one_port(lldpd1, lldpd, lldpcli, namespaces, links): assert out['lldp.eth2.port.power.device-type'] == 'PSE' -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_new_port_take_default(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): @@ -395,7 +395,7 @@ def test_new_port_take_default(lldpd1, lldpd, lldpcli, namespaces, links): assert out['lldp.eth3.port.power.device-type'] == 'PSE' -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_port_keep_configuration_when_down(lldpd, lldpcli, namespaces, links): with namespaces(1): @@ -419,7 +419,7 @@ def test_port_keep_configuration_when_down(lldpd, lldpcli, namespaces, links): assert out['lldp.eth3.port.power.device-type'] == 'PSE' -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_port_forget_configuration(lldpd, lldpcli, namespaces, links): @@ -438,7 +438,7 @@ def test_port_forget_configuration(lldpd, lldpcli, assert 'lldp.eth3.port.power.device-type' not in out -@pytest.mark.skipif('Dot3' not in pytest.config.lldpd.features, +@pytest.mark.skipif("'Dot3' not in config.lldpd.features", reason="Dot3 not supported") def test_port_keep_configuration_of_permanent_ports(lldpd, lldpcli, namespaces, links): @@ -494,7 +494,7 @@ def test_watch(lldpd1, lldpd, lldpcli, namespaces, links): assert got == expected -@pytest.mark.skipif('XML' not in pytest.config.lldpcli.outputs, +@pytest.mark.skipif("'XML' not in config.lldpcli.outputs", reason="XML not supported") def test_watch_xml(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): @@ -521,7 +521,7 @@ def test_watch_xml(lldpd1, lldpd, lldpcli, namespaces, links): assert ET.tostring(got) == ET.tostring(expected) -@pytest.mark.skipif('JSON' not in pytest.config.lldpcli.outputs, +@pytest.mark.skipif("'JSON' not in config.lldpcli.outputs", reason="JSON not supported") def test_watch_json(lldpd1, lldpd, lldpcli, namespaces, links): with namespaces(2): @@ -564,14 +564,14 @@ def test_return_code(lldpd1, lldpcli, namespaces): ("configure lldp portidsubtype ifname", "lldp-portid-type", "ifname"), pytest.param("unconfigure med fast-start", "lldpmed-faststart", "no", - marks=pytest.mark.skipif('LLDP-MED' - not in pytest.config.lldpd.features, - reason="LLDP-MED not supported")), + marks=pytest.mark.skipif( + "'LLDP-MED' not in config.lldpd.features", + reason="LLDP-MED not supported")), pytest.param("configure med fast-start tx-interval 2", "lldpmed-faststart-interval", 2, - marks=pytest.mark.skipif('LLDP-MED' - not in pytest.config.lldpd.features, - reason="LLDP-MED not supported")), + marks=pytest.mark.skipif( + "'LLDP-MED' not in config.lldpd.features", + reason="LLDP-MED not supported")), ("configure system interface pattern eth*", "iface-pattern", "eth*"), ("configure system interface permanent eth*", "perm-iface-pattern", "eth*"), diff --git a/tests/integration/test_med.py b/tests/integration/test_med.py index 4a7285ac..4f13d858 100644 --- a/tests/integration/test_med.py +++ b/tests/integration/test_med.py @@ -4,7 +4,7 @@ import time import shlex -@pytest.mark.skipif('LLDP-MED' not in pytest.config.lldpd.features, +@pytest.mark.skipif('LLDP"-MED' not in config.lldpd.features", reason="LLDP-MED not supported") class TestLldpMed(object): diff --git a/tests/integration/test_pcap.py b/tests/integration/test_pcap.py index 3058f045..c75b0b2e 100644 --- a/tests/integration/test_pcap.py +++ b/tests/integration/test_pcap.py @@ -25,7 +25,7 @@ def send_pcap(location, interface): class TestPcapCaptures(object): - def test_cisco_sg200(self, lldpd1, lldpcli, namespaces): + def test_cisco_sg200(self, request, lldpd1, lldpcli, namespaces): with namespaces(2): send_pcap('data/sg200.pcap', 'eth1') with namespaces(1): @@ -39,7 +39,7 @@ class TestPcapCaptures(object): "lldp.eth0.port.ttl": "120", "lldp.eth0.port.ifname": "g1", } - if 'Dot3' in pytest.config.lldpd.features: + if 'Dot3' in request.config.lldpd.features: expected.update({ "lldp.eth0.port.auto-negotiation.supported": "yes", "lldp.eth0.port.auto-negotiation.enabled": "yes", @@ -47,7 +47,7 @@ class TestPcapCaptures(object): "lldp.eth0.port.auto-negotiation.1000Base-T.fd": "yes", "lldp.eth0.port.auto-negotiation.current": "unknown", }) - if 'LLDP-MED' in pytest.config.lldpd.features: + if 'LLDP-MED' in request.config.lldpd.features: expected.update({ "lldp.eth0.lldp-med.device-type": "Network Connectivity Device", diff --git a/tests/integration/test_protocols.py b/tests/integration/test_protocols.py index 487df8c4..1dc3ed0d 100644 --- a/tests/integration/test_protocols.py +++ b/tests/integration/test_protocols.py @@ -2,7 +2,7 @@ import pytest import pyroute2 -@pytest.mark.skipif('CDP' not in pytest.config.lldpd.protocols, +@pytest.mark.skipif("'CDP' not in config.lldpd.protocols", reason="CDP not supported") @pytest.mark.parametrize("argument, expected", [ ("-cc", "CDPv1"), @@ -25,7 +25,7 @@ def test_cdp(lldpd, lldpcli, links, namespaces, assert out["lldp.eth0.port.descr"] == "eth1" -@pytest.mark.skipif('FDP' not in pytest.config.lldpd.protocols, +@pytest.mark.skipif("'FDP' not in config.lldpd.protocols", reason="FDP not supported") def test_fdp(lldpd, lldpcli, links, namespaces): links(namespaces(1), namespaces(2)) @@ -44,7 +44,7 @@ def test_fdp(lldpd, lldpcli, links, namespaces): assert out["lldp.eth0.port.descr"] == "eth1" -@pytest.mark.skipif('EDP' not in pytest.config.lldpd.protocols, +@pytest.mark.skipif("'EDP' not in config.lldpd.protocols", reason="EDP not supported") def test_edp(lldpd, lldpcli, links, namespaces): links(namespaces(1), namespaces(2)) @@ -63,7 +63,7 @@ def test_edp(lldpd, lldpcli, links, namespaces): assert out["lldp.eth0.port.descr"] == "Slot 1 / Port 2" -@pytest.mark.skipif('SONMP' not in pytest.config.lldpd.protocols, +@pytest.mark.skipif("'SONMP' not in config.lldpd.protocols", reason="SONMP not supported") def test_sonmp(lldpd, lldpcli, links, namespaces): links(namespaces(1), namespaces(2)) diff --git a/tests/integration/test_snmp.py b/tests/integration/test_snmp.py index 2a3e85da..6eedded6 100644 --- a/tests/integration/test_snmp.py +++ b/tests/integration/test_snmp.py @@ -1,7 +1,7 @@ import pytest import time -pytestmark = pytest.mark.skipif(not pytest.config.lldpd.snmp, +pytestmark = pytest.mark.skipif("not config.lldpd.snmp", reason="no SNMP support")