[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Loosen regex metching for python 2.6 assertions
commit e69d22fdf8003e0422fd97d4de7538947a1d2fb4
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Fri Oct 27 09:43:47 2017 -0700
Loosen regex metching for python 2.6 assertions
Python 2.6 lacks assertRaisesRegexp so we made our own handler for it. However,
the assertions it did were more strict, causing failures for tests that pass
with other python versions...
======================================================================
FAIL: test_get_info_address_caching
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/mock.py", line 1201, in patched
return func(*args, **keywargs)
File "/home/atagar/Desktop/stem/test/unit/control/controller.py", line 61, in test_get_info_address_caching
self.assertRaisesRegexp(stem.ProtocolError, 'Address unknown', self.controller.get_info, 'address')
File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 270, in assertRaisesRegexp
self.assertTrue(re.match(exc_msg, str(exc)))
AssertionError
---
stem/util/test_tools.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index 62ca1577..c6e2b304 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -273,7 +273,7 @@ class TimedTestRunner(unittest.TextTestRunner):
func(*args, **kwargs)
self.fail('Expected a %s to be raised but nothing was' % exc_type)
except exc_type as exc:
- self.assertTrue(re.match(exc_msg, str(exc)))
+ self.assertTrue(re.search(exc_msg, str(exc), re.MULTILINE))
else:
return super(original_type, self).assertRaisesRegexp(exc_type, exc_msg, func, *args, **kwargs)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits