]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
tests: don't use pytest.config
authorVincent Bernat <vincent@bernat.ch>
Sun, 15 Sep 2019 17:19:06 +0000 (19:19 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sun, 15 Sep 2019 17:19:06 +0000 (19:19 +0200)
It's deprecated in 5.0.

tests/integration/test_custom.py
tests/integration/test_dot1.py
tests/integration/test_dot3.py
tests/integration/test_interfaces.py
tests/integration/test_lldpcli.py
tests/integration/test_med.py
tests/integration/test_pcap.py
tests/integration/test_protocols.py
tests/integration/test_snmp.py

index 54a05ae3b6949d18ffd19e85eb4d23e88ef8843a..a2d6dc79b7e61abbe180c3cd355520aa236cee0c 100644 (file)
@@ -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"],
index 79f120fad8b07b5d9cfddaa107fa6a6b13222ca3..ba16baa4c0967409149a4b3e5344cd25d2f06f35 100644 (file)
@@ -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):
 
index 6f311953bc01671f6f09d2fdf849e93d8aff9bc6..1eb5ee46db34a66e4cf9412bee020988870cc728 100644 (file)
@@ -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):
 
index 22cb0792c5a2c5f228739b7fabb8806163c70654..77fece6d54f2f9b504d1b77e06da536b3f81dec7 100644 (file)
@@ -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):
index 8949d6f64eb17717ecea49ac3c77738e95e5e16c..04c58a11926271f8eaac9c4890bf0a78e550df94 100644 (file)
@@ -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,
  </interface>
 </lldp>
 """)], 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 = """
    <auto-negotiation enabled="no" label="PMD autoneg" supported="no">
     <current label="MAU oper type">10GigBaseCX4 - X copper over 8 pair 100-Ohm balanced cable</current>
@@ -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*"),
index 4a7285ac9d396b0a48df6aceb6dcc204003596f7..4f13d858770595c17ea1847fe3f7500794e12558 100644 (file)
@@ -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):
 
index 3058f045bc900f4df0f7a50115a7f991e3a1aa45..c75b0b2e9078c3a06a8cb8e34f0198603c774b65 100644 (file)
@@ -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",
index 487df8c43e18570337d7faa2ca16aae9483e9438..1dc3ed0d4c3f7b3297180a9f60a0bb41d50038ab 100644 (file)
@@ -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))
index 2a3e85dab042528d8fca3481a23b5371a87641cd..6eedded63b8cb344d9d6d5709b9f0bc5ca316577 100644 (file)
@@ -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")