Permalink
Browse files

Run the tests in optimized mode too to ensure that things still work

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).
  • Loading branch information...
bdarnell committed Jun 13, 2012
1 parent 4c23060 commit 577e9a0c816d41a3b3427afd545d09c366a3b950
Showing with 22 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 tornado/simple_httpclient.py
  3. +17 −1 tox.ini
View
@@ -1,4 +1,5 @@
*.pyc
+*.pyo
*.so
*.class
*~
@@ -364,8 +364,10 @@ def _on_headers(self, data):
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
View
18 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:}

0 comments on commit 577e9a0

Please sign in to comment.