summaryrefslogtreecommitdiffstats
path: root/netaddr/tests/ip/test_ip.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 17:45:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 17:45:09 +0000
commitda1a8f12d7a38f67f3f464aaaffa851f929ae4ea (patch)
tree677688f3aeab7f324f266d106770165708522c2c /netaddr/tests/ip/test_ip.py
parentInitial commit. (diff)
downloadpython-netaddr-upstream.tar.xz
python-netaddr-upstream.zip
Adding upstream version 0.10.1.upstream/0.10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netaddr/tests/ip/test_ip.py')
-rw-r--r--netaddr/tests/ip/test_ip.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/netaddr/tests/ip/test_ip.py b/netaddr/tests/ip/test_ip.py
new file mode 100644
index 0000000..94cfc0c
--- /dev/null
+++ b/netaddr/tests/ip/test_ip.py
@@ -0,0 +1,19 @@
+import weakref
+
+import pytest
+
+from netaddr import INET_ATON, INET_PTON, IPAddress, IPNetwork, IPRange, NOHOST
+
+def test_ip_classes_are_weak_referencable():
+ weakref.ref(IPAddress('10.0.0.1'))
+ weakref.ref(IPNetwork('10.0.0.1/8'))
+ weakref.ref(IPRange('10.0.0.1', '10.0.0.10'))
+
+@pytest.mark.parametrize('flags', [NOHOST, INET_ATON | INET_PTON])
+def test_invalid_ipaddress_flags_are_rejected(flags):
+ with pytest.raises(ValueError):
+ IPAddress('1.2.3.4', flags=flags)
+
+def test_invalid_ipnetwork_flags_are_rejected():
+ with pytest.raises(ValueError):
+ IPNetwork('1.2.0.0/16', flags=INET_PTON)