diff options
author | Robert Collins <robertc@robertcollins.net> | 2012-12-17 13:35:34 +1300 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2012-12-17 13:35:34 +1300 |
commit | 039ff7b76ca753b9241724f63e3acc67ff623afb (patch) | |
tree | 56d116e62a759f004848b6d8680ee7730adfcc02 | |
parent | 639573c78745eeade117e9dc29baf11e5456e461 (diff) | |
download | fixtures-039ff7b76ca753b9241724f63e3acc67ff623afb.tar.gz |
0.3.12: 0.3.11 with tests for StringStream.0.3.12
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | lib/fixtures/__init__.py | 2 | ||||
-rw-r--r-- | lib/fixtures/_fixtures/streams.py | 2 | ||||
-rw-r--r-- | lib/fixtures/tests/_fixtures/test_streams.py | 42 | ||||
-rwxr-xr-x | setup.py | 2 |
5 files changed, 48 insertions, 5 deletions
@@ -6,6 +6,11 @@ fixtures release notes NEXT ~~~~ +0.3.12 +~~~~~~ + +Brown bag fix up of StringStream from 0.3.11. + 0.3.11 ~~~~~~ diff --git a/lib/fixtures/__init__.py b/lib/fixtures/__init__.py index 1472945..f2d9a2f 100644 --- a/lib/fixtures/__init__.py +++ b/lib/fixtures/__init__.py @@ -36,7 +36,7 @@ Most users will want to look at TestWithFixtures and Fixture, to start with. # established at this point, and setup.py will use a version of next-$(revno). # If the releaselevel is 'final', then the tarball will be major.minor.micro. # Otherwise it is major.minor.micro~$(revno). -__version__ = (0, 3, 11, 'final', 0) +__version__ = (0, 3, 12, 'final', 0) __all__ = [ 'ByteStream', diff --git a/lib/fixtures/_fixtures/streams.py b/lib/fixtures/_fixtures/streams.py index 654ee67..188d8e3 100644 --- a/lib/fixtures/_fixtures/streams.py +++ b/lib/fixtures/_fixtures/streams.py @@ -68,6 +68,8 @@ def ByteStream(detail_name): def _string_stream_factory(): lower = io.BytesIO() upper = io.TextIOWrapper(lower, encoding="utf8") + # See http://bugs.python.org/issue7955 + upper._CHUNK_SIZE = 1 # In theory, this is sufficient and correct, but on Python2, # upper.write(_b('foo")) will whinge louadly. if sys.version_info[0] < 3: diff --git a/lib/fixtures/tests/_fixtures/test_streams.py b/lib/fixtures/tests/_fixtures/test_streams.py index b4f4838..68396cd 100644 --- a/lib/fixtures/tests/_fixtures/test_streams.py +++ b/lib/fixtures/tests/_fixtures/test_streams.py @@ -37,14 +37,14 @@ class TestByteStreams(TestCase): def test_empty_detail_stream(self): detail_name = 'test' - fixture = DetailStream(detail_name) + fixture = ByteStream(detail_name) with fixture: content = fixture.getDetails()[detail_name] self.assertEqual(_u(""), content.as_text()) def test_stream_content_in_details(self): detail_name = 'test' - fixture = DetailStream(detail_name) + fixture = ByteStream(detail_name) with fixture: stream = fixture.stream content = fixture.getDetails()[detail_name] @@ -54,7 +54,7 @@ class TestByteStreams(TestCase): def test_stream_content_reset(self): detail_name = 'test' - fixture = DetailStream(detail_name) + fixture = ByteStream(detail_name) with fixture: stream = fixture.stream content = fixture.getDetails()[detail_name] @@ -67,3 +67,39 @@ class TestByteStreams(TestCase): stream = fixture.stream stream.write(_b("1 2 3 testing")) self.assertEqual(_u("1 2 3 testing"), content.as_text()) + + +class TestStringStreams(TestCase): + + def test_empty_detail_stream(self): + detail_name = 'test' + fixture = StringStream(detail_name) + with fixture: + content = fixture.getDetails()[detail_name] + self.assertEqual(_u(""), content.as_text()) + + def test_stream_content_in_details(self): + detail_name = 'test' + fixture = StringStream(detail_name) + with fixture: + stream = fixture.stream + content = fixture.getDetails()[detail_name] + # Output after getDetails is called is included. + stream.write(_u("testing 1 2 3")) + self.assertEqual("testing 1 2 3", content.as_text()) + + def test_stream_content_reset(self): + detail_name = 'test' + fixture = StringStream(detail_name) + with fixture: + stream = fixture.stream + content = fixture.getDetails()[detail_name] + stream.write(_u("testing 1 2 3")) + with fixture: + # The old content object returns the old usage + self.assertEqual(_u("testing 1 2 3"), content.as_text()) + content = fixture.getDetails()[detail_name] + # A new fixture returns the new output: + stream = fixture.stream + stream.write(_u("1 2 3 testing")) + self.assertEqual(_u("1 2 3 testing"), content.as_text()) @@ -6,7 +6,7 @@ import os.path description = open(os.path.join(os.path.dirname(__file__), 'README'), 'rt').read() setup(name="fixtures", - version="0.3.11", + version="0.3.12", description="Fixtures, reusable state for writing clean tests and more.", keywords="fixture fixtures unittest contextmanager", long_description=description, |