Skip to content

Commit

Permalink
Run the tests in optimized mode too to ensure that things still work
Browse files Browse the repository at this point in the history
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 577e9a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
*.pyo
*.so
*.class
*~
Expand Down
6 changes: 4 additions & 2 deletions tornado/simple_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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:}

Expand Down Expand Up @@ -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.