diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2009-06-02 05:46:01 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2009-06-02 05:46:01 (GMT) |
commit | 0a27e3db50193de0881d98f9bc856e18f079974e (patch) | |
tree | 26494000d06c5ccfb33feaacc8c31d93dc99cedb | |
parent | 181bdc63741087bb43e299b0d3fa60b732894c7a (diff) | |
download | cpython-0a27e3db50193de0881d98f9bc856e18f079974e.zip cpython-0a27e3db50193de0881d98f9bc856e18f079974e.tar.gz cpython-0a27e3db50193de0881d98f9bc856e18f079974e.tar.bz2 |
Add test code to verify that relative comparison operators with an object
of the wrong type fail properly (TypeError is raised).
-rwxr-xr-x | Lib/test/test_ipaddr.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_ipaddr.py b/Lib/test/test_ipaddr.py index d00d3d8..a7799f7 100755 --- a/Lib/test/test_ipaddr.py +++ b/Lib/test/test_ipaddr.py @@ -396,6 +396,16 @@ class IpaddrUnitTest(unittest.TestCase): self.assertFalse(ip2 > ip3) self.assertTrue(ip3 > ip2) + # Confirm that relative comparisons to the wrong type fail properly. + self.assertRaises(TypeError, lambda: ipv4 < '') + self.assertRaises(TypeError, lambda: ipv4 > '') + self.assertRaises(TypeError, lambda: ipv4 >= '') + self.assertRaises(TypeError, lambda: ipv4 <= '') + self.assertRaises(TypeError, lambda: ipv6 < '') + self.assertRaises(TypeError, lambda: ipv6 > '') + self.assertRaises(TypeError, lambda: ipv6 >= '') + self.assertRaises(TypeError, lambda: ipv6 <= '') + def test_embedded_ipv4(self): ipv4_string = '192.168.0.1' ipv4 = ipaddr.IPv4(ipv4_string) |