]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add more warnings filters in twisted_test.
authorBen Darnell <ben@bendarnell.com>
Fri, 7 Aug 2015 16:07:58 +0000 (12:07 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 7 Aug 2015 16:07:58 +0000 (12:07 -0400)
Necessary for green builds with Twisted 15.3 on Python 3.x.

tornado/test/twisted_test.py

index 22410567a8955f0dff2601ad8614fbb12358d37b..c921c5fb12b2910f53f46cd648100206ed4b9827 100644 (file)
@@ -630,6 +630,24 @@ if have_twisted:
                     os.chdir(self.__curdir)
                     shutil.rmtree(self.__tempdir)
 
+                def flushWarnings(self, *args, **kwargs):
+                    # This is a hack because Twisted and Tornado have
+                    # differing approaches to warnings in tests.
+                    # Tornado sets up a global set of warnings filters
+                    # in runtests.py, while Twisted patches the filter
+                    # list in each test. The net effect is that
+                    # Twisted's tests run with Tornado's increased
+                    # strictness (BytesWarning and ResourceWarning are
+                    # enabled) but without our filter rules to ignore those
+                    # warnings from Twisted code.
+                    filtered = []
+                    for w in super(TornadoTest, self).flushWarnings(
+                            *args, **kwargs):
+                        if w['category'] in (BytesWarning, ResourceWarning):
+                            continue
+                        filtered.append(w)
+                    return filtered
+
                 def buildReactor(self):
                     self.__saved_signals = save_signal_handlers()
                     return test_class.buildReactor(self)