summaryrefslogtreecommitdiff
path: root/lib/fixtures
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fixtures')
-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
3 files changed, 42 insertions, 4 deletions
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())