]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Run the tests in optimized mode too to ensure that things still work
authorBen Darnell <ben@bendarnell.com>
Wed, 13 Jun 2012 17:55:46 +0000 (10:55 -0700)
committerBen Darnell <ben@bendarnell.com>
Wed, 13 Jun 2012 17:58:15 +0000 (10:58 -0700)
without assertions.

Fix one assert that should have been a runtime error (there are probably
more, but this is the only one currently covered by the test suite).

.gitignore
tornado/simple_httpclient.py
tox.ini

index 0e0a11e8d271602a6807e8e089af82ad59b4be76..c84e747f4341e8b3e111c19299d8a77fe3b7dada 100644 (file)
@@ -1,4 +1,5 @@
 *.pyc
+*.pyo
 *.so
 *.class
 *~
index f5f075fa84fe598bd12a6500d8d917255f0fd2e0..c6e8a3a7ce0e0594d725cf5a09571651ab69b779 100644 (file)
@@ -364,8 +364,10 @@ class _HTTPConnection(object):
         if 100 <= self.code < 200 or self.code in (204, 304):
             # These response codes never have bodies
             # http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
-            assert "Transfer-Encoding" not in self.headers
-            assert content_length in (None, 0)
+            if ("Transfer-Encoding" in self.headers or
+                content_length not in (None, 0)):
+                raise ValueError("Response with code %d should not have body" %
+                                 self.code)
             self._on_body(b(""))
             return
 
diff --git a/tox.ini b/tox.ini
index 40909881cdffa2ccb4cd1070832f634218916884..27189a48eb7770d07c8576fc06d6cb03e73754c2 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -13,7 +13,7 @@
 [tox]
 # "-full" variants include optional dependencies, to ensure
 # that things work both in a bare install and with all the extras.
-envlist = py27-full, py27-curl, py25-full, py32, pypy, py25, py26, py26-full, py27, py32-utf8, py33
+envlist = py27-full, py27-curl, py25-full, py32, pypy, py25, py26, py26-full, py27, py32-utf8, py33, py27-opt, py32-opt
 [testenv]
 commands = python -m tornado.test.runtests {posargs:}
 
@@ -87,3 +87,19 @@ setenv = LANG=en_US.utf-8
 [testenv:py33]
 # tox doesn't yet know "py33" by default
 basepython = python3.3
+
+# Python's optimized mode disables the assert statement, so run the
+# tests in this mode to ensure we haven't fallen into the trap of relying
+# on an assertion's side effects or using them for things that should be
+# runtime errors.
+[testenv:py27-opt]
+basepython = python2.7
+deps =
+     MySQL-python
+     pycurl
+     twisted>=12.0.0
+commands = python -O -m tornado.test.runtests {posargs:}
+
+[testenv:py32-opt]
+basepython = python3.2
+commands = python -O -m tornado.test.runtests {posargs:}