[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Duplicate ports could cause test failures
commit 8523cae6928c27c90a4394a326e00cd9dc9630dd
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Jan 20 18:14:32 2020 -0800
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.
---
bridgedb/test/test_parse_addr.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bridgedb/test/test_parse_addr.py b/bridgedb/test/test_parse_addr.py
index 41cbb94..b32d359 100644
--- a/bridgedb/test/test_parse_addr.py
+++ b/bridgedb/test/test_parse_addr.py
@@ -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.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits