Unverified Commit 8523cae6 authored by Damian Johnson's avatar Damian Johnson Committed by Philipp Winter
Browse files

Duplicate ports could cause test failures

Not python 3 related, but when picking random ports if we have a duplicate our
tests fail with...

  Traceback (most recent call last):
    File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_parse_addr.py", line 676, in test_tooManyPorts
      self.assertEqual(len(portList), tooMany)
    File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 432, in assertEqual
      super(_Assertions, self).assertEqual(first, second, msg)
    File "/usr/lib/python3.5/unittest/case.py", line 820, in assertEqual
      assertion_func(first, second, msg=msg)
    File "/usr/lib/python3.5/unittest/case.py", line 813, in _baseAssertEqual
      raise self.failureException(msg)
  twisted.trial.unittest.FailTest: 16 != 17

This is because portList deduplicates inputs in its add() method.
parent 1767e28d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -673,7 +673,7 @@ class PortListTest(unittest.TestCase):
        log.msg("Testing addr.PortList(%s))"
                % ', '.join([type('')(port) for port in ports]))
        portList = addr.PortList(*ports)
        self.assertEqual(len(portList), tooMany)
        self.assertEqual(len(portList), len(set(ports)))

    def test_invalidPortNumber(self):
        """Test creating a :class:`addr.PortList` with an invalid port.