[tor-commits] [bridgedb/master] Add two unittests for PortList.__getitem__ to debug #10333.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:34 UTC 2014


commit 63b5a6e3f334a0e6ba09a316692cb2a32d01df49
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed Dec 11 04:35:48 2013 +0000

    Add two unittests for PortList.__getitem__ to debug #10333.
---
 lib/bridgedb/test/test_parse_addr.py |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_addr.py b/lib/bridgedb/test/test_parse_addr.py
index e29c554..9714cc1 100644
--- a/lib/bridgedb/test/test_parse_addr.py
+++ b/lib/bridgedb/test/test_parse_addr.py
@@ -591,6 +591,18 @@ class PortListTest(unittest.TestCase):
         portList = addr.PortList(*ports)
         self.assertRaises(IndexError, portList.__getitem__, 555)
 
+    def test_getitem_string(self):
+        """Test ``__getitem__`` with a string."""
+        ports = (443, 9001, 9030)
+        portList = addr.PortList(*ports)
+        self.assertRaises(TypeError, portList.__getitem__, '443')
+
+    def test_getitem_long(self):
+        """Test ``__getitem__`` with a string."""
+        ports = (443, 9001, 9030)
+        portList = addr.PortList(*ports)
+        self.assertEqual(portList.__getitem__(long(0)), 9001)
+
     def test_mixedArgs(self):
         """Create a :class:`addr.PortList` with mixed type parameters."""
         firstList = addr.PortList('1111,2222,3333')





More information about the tor-commits mailing list