summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--lib/fixtures/__init__.py2
-rw-r--r--lib/fixtures/_fixtures/streams.py2
-rw-r--r--lib/fixtures/tests/_fixtures/test_streams.py42
-rwxr-xr-xsetup.py2
5 files changed, 48 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index f1dda1e..a79557d 100644
--- a/NEWS
+++ b/NEWS
@@ -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())
diff --git a/setup.py b/setup.py
index 79f86a5..918203f 100755
--- a/setup.py
+++ b/setup.py
@@ -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,