testtools-dev team mailing list archive
-
testtools-dev team
-
Mailing list archive
-
Message #00954
[Merge] lp:~gz/testtools/pass_testsuite_0.9.12 into lp:testtools
Martin Packman has proposed merging lp:~gz/testtools/pass_testsuite_0.9.12 into lp:testtools.
Requested reviews:
testtools committers (testtools-committers)
For more details, see:
https://code.launchpad.net/~gz/testtools/pass_testsuite_0.9.12/+merge/86489
An exciting new instalment in changes to get the test suite passing on trunk against various Python versions on my box. Oh, and pypy too.
The good is everything mostly works... the bad is most of the tests I had to make even uglier were my fault in the first place. I need some kind of multiline matcher that can just say it doesn't care, plus or minus one space, where the caret in a SyntaxError is...
--
https://code.launchpad.net/~gz/testtools/pass_testsuite_0.9.12/+merge/86489
Your team testtools developers is subscribed to branch lp:testtools.
=== modified file 'testtools/matchers.py'
--- testtools/matchers.py 2011-12-07 11:30:08 +0000
+++ testtools/matchers.py 2011-12-21 01:35:27 +0000
@@ -1234,13 +1234,20 @@
def __init__(self, paths):
super(TarballContains, self).__init__()
self.paths = paths
+ self.path_matcher = Equals(sorted(self.paths))
def match(self, tarball_path):
- tarball = tarfile.open(tarball_path)
+ # Open underlying file first to ensure it's always closed:
+ # <http://bugs.python.org/issue10233>
+ f = open(tarball_path, "rb")
try:
- return Equals(sorted(self.paths)).match(sorted(tarball.getnames()))
+ tarball = tarfile.open(tarball_path, fileobj=f)
+ try:
+ return self.path_matcher.match(sorted(tarball.getnames()))
+ finally:
+ tarball.close()
finally:
- tarball.close()
+ f.close()
class SamePath(Matcher):
=== modified file 'testtools/tests/test_compat.py'
--- testtools/tests/test_compat.py 2011-09-13 23:15:23 +0000
+++ testtools/tests/test_compat.py 2011-12-21 01:35:27 +0000
@@ -95,7 +95,7 @@
"\xef\xbb\xbfimport sys\n",
))
self._check_encoding("utf-8", (
- "\xef\xbb\xbf# File encoding: UTF-8\n",
+ "\xef\xbb\xbf# File encoding: utf-8\n",
))
self._check_encoding("utf-8", (
'\xef\xbb\xbf"""Module docstring\n',
=== modified file 'testtools/tests/test_content.py'
--- testtools/tests/test_content.py 2011-04-20 23:45:52 +0000
+++ testtools/tests/test_content.py 2011-12-21 01:35:27 +0000
@@ -130,11 +130,12 @@
def test_from_stream_eager_loading(self):
fd, path = tempfile.mkstemp()
self.addCleanup(os.remove, path)
+ self.addCleanup(os.close, fd)
os.write(fd, _b('some data'))
stream = open(path, 'rb')
+ self.addCleanup(stream.close)
content = content_from_stream(stream, UTF8_TEXT, buffer_now=True)
os.write(fd, _b('more data'))
- os.close(fd)
self.assertThat(
''.join(content.iter_text()), Equals('some data'))
=== modified file 'testtools/tests/test_matchers.py'
--- testtools/tests/test_matchers.py 2011-12-07 11:30:08 +0000
+++ testtools/tests/test_matchers.py 2011-12-21 01:35:27 +0000
@@ -1299,13 +1299,14 @@
self.assertThat(abspath, SamePath(path))
def test_real_path(self):
- symlink = getattr(os, 'symlink', None)
- skipIf(symlink is None, "No symlink support")
tempdir = self.mkdtemp()
source = os.path.join(tempdir, 'source')
self.touch(source)
target = os.path.join(tempdir, 'target')
- symlink(source, target)
+ try:
+ os.symlink(source, target)
+ except (AttributeError, NotImplementedError):
+ self.skip("No symlink support")
self.assertThat(source, SamePath(target))
self.assertThat(target, SamePath(source))
=== modified file 'testtools/tests/test_testresult.py'
--- testtools/tests/test_testresult.py 2011-11-17 15:43:49 +0000
+++ testtools/tests/test_testresult.py 2011-12-21 01:35:27 +0000
@@ -1163,8 +1163,10 @@
_u("\u5357\u7121"), # In ISO 2022 encodings
_u("\xa7\xa7\xa7"), # In ISO 8859 encodings
)
+
+ _is_pypy = "__pypy__" in sys.builtin_module_names
# Everything but Jython shows syntax errors on the current character
- _error_on_character = os.name != "java"
+ _error_on_character = os.name != "java" and not _is_pypy
def _run(self, stream, test):
"""Run the test, the same as in testtools.run but not to stdout"""
@@ -1412,6 +1414,9 @@
self._write_module("bad", "euc_jp",
"# coding: euc_jp\n$ = 0 # %s\n" % text)
textoutput = self._run_external_case()
+ # pypy uses cpython's multibyte codecs so has their behavior here
+ if self._is_pypy:
+ self._error_on_character = True
self.assertIn(self._as_output(_u(
#'bad.py", line 2\n'
' $ = 0 # %s\n'
Follow ups