]>
Commit | Line | Data |
---|---|---|
009884d2 ER |
1 | From 80071f4450261b70b70f537bc2b54d2c97d9f562 Mon Sep 17 00:00:00 2001 |
2 | From: "David P. D. Moss" <drkjam@gmail.com> | |
3 | Date: Thu, 25 Nov 2010 08:53:49 +0000 | |
4 | Subject: [PATCH] Fixed github Issue no. 2. Thanks keesbos. | |
5 | ||
6 | --- | |
7 | netaddr/ip/__init__.py | 2 ++ | |
8 | netaddr/tests/2.x/ip/constructor.txt | 11 +++++++++++ | |
9 | netaddr/tests/3.x/ip/constructor.txt | 11 +++++++++++ | |
10 | 3 files changed, 24 insertions(+), 0 deletions(-) | |
11 | ||
12 | diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py | |
13 | index 0179c38..e4a6b7b 100644 | |
14 | --- a/netaddr/ip/__init__.py | |
15 | +++ b/netaddr/ip/__init__.py | |
16 | @@ -779,6 +779,8 @@ def parse_ip_network(module, addr, implicit_prefix=False, flags=0): | |
17 | # Try a partial IPv4 network address... | |
18 | expanded_addr = _ipv4.expand_partial_address(val1) | |
19 | ip = IPAddress(expanded_addr, module.version, flags=INET_PTON) | |
20 | + else: | |
21 | + raise AddrFormatError('invalid IPNetwork address %s!' % addr) | |
22 | value = ip._value | |
23 | ||
24 | try: | |
25 | diff --git a/netaddr/tests/2.x/ip/constructor.txt b/netaddr/tests/2.x/ip/constructor.txt | |
26 | index f67f5e4..5a9e978 100644 | |
27 | --- a/netaddr/tests/2.x/ip/constructor.txt | |
28 | +++ b/netaddr/tests/2.x/ip/constructor.txt | |
29 | @@ -209,3 +209,14 @@ IPNetwork('172.24.0.0/16') | |
30 | ||
31 | ||
32 | }}} | |
33 | + | |
34 | +Negative testing | |
35 | + | |
36 | +{{{ | |
37 | + | |
38 | +>>> IPNetwork('foo') | |
39 | +Traceback (most recent call last): | |
40 | +... | |
41 | +AddrFormatError: invalid IPNetwork foo | |
42 | + | |
43 | +}}} | |
44 | diff --git a/netaddr/tests/3.x/ip/constructor.txt b/netaddr/tests/3.x/ip/constructor.txt | |
45 | index 2ec47c0..35a5cd6 100644 | |
46 | --- a/netaddr/tests/3.x/ip/constructor.txt | |
47 | +++ b/netaddr/tests/3.x/ip/constructor.txt | |
48 | @@ -209,3 +209,14 @@ IPNetwork('172.24.0.0/16') | |
49 | ||
50 | ||
51 | }}} | |
52 | + | |
53 | +Negative testing | |
54 | + | |
55 | +{{{ | |
56 | + | |
57 | +>>> IPNetwork('foo') | |
58 | +Traceback (most recent call last): | |
59 | +... | |
60 | +netaddr.core.AddrFormatError: invalid IPNetwork foo | |
61 | + | |
62 | +}}} | |
63 | -- | |
64 | 1.7.5.2 | |
65 |