From 207eee8c0fc006c253eeade3efc61c3937074f0a Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: Tue, 11 Jul 2023 11:49:48 +0200 Subject: [PATCH] re-import sources as agreed with the maintainer --- .gitignore | 4 +++- tests/test_netifaces.py | 30 ++++++++++++++++++++++++++++++ tests/tests.yml | 13 +++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/test_netifaces.py create mode 100644 tests/tests.yml diff --git a/.gitignore b/.gitignore index 6bcbc34..fbd29cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -SOURCES/netifaces-0.10.6.tar.gz +/netifaces-0.5.tar.gz +/netifaces-0.10.4.tar.gz +/netifaces-0.10.5.tar.gz /netifaces-0.10.6.tar.gz diff --git a/tests/test_netifaces.py b/tests/test_netifaces.py new file mode 100644 index 0000000..471797a --- /dev/null +++ b/tests/test_netifaces.py @@ -0,0 +1,30 @@ +import netifaces +import pytest + + +def test_interfaces(): + ifaces = netifaces.interfaces() + assert isinstance(ifaces, list) + assert "lo" in ifaces + + +@pytest.mark.parametrize( + "iface,af,expected", + [ + ("lo", netifaces.AF_INET, "127.0.0.1"), + ("lo", netifaces.AF_INET6, "::1"), + ], +) +def test_ifaddresses_lo(iface, af, expected): + addrs = netifaces.ifaddresses(iface) + assert addrs[af][0]["addr"] == expected + + +def test_invalid(): + with pytest.raises(ValueError): + netifaces.ifaddresses("invalid interface") + + +def test_gateways(): + gw = netifaces.gateways() + assert "default" in gw diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..ee90341 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-basic + required_packages: + - python3-netifaces + - python3-pytest + tests: + - unittests: + dir: "." + run: pytest-3 test_netifaces.py