summaryrefslogtreecommitdiff
path: root/lib/fixtures/tests/_fixtures/test_streams.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fixtures/tests/_fixtures/test_streams.py')
-rw-r--r--lib/fixtures/tests/_fixtures/test_streams.py42
1 files changed, 39 insertions, 3 deletions
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())