From b33d25d72bb0eeeafeedb0e03755e9eab40ab9ba Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Mon, 11 Aug 2008 22:05:06 +0000 Subject: =?UTF-8?q?Bug=20547354=20=E2=80=93=20wrap=20a=20few=20memory=20st?= =?UTF-8?q?ream=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-08-12 Paul Pogonyshev Bug 547354 – wrap a few memory stream methods * gio/ginputstream.override (_wrap_g_memory_input_stream_add_data): New function. * gio/gio.defs (gio.MemoryOutputStream.get_contents): Rename from get_data() to avoid name clash. * gio/goutputstream.override (_wrap_g_memory_output_stream_new) (_wrap_g_memory_output_stream_get_data): New functions. * tests/test_gio.py (TestMemoryInputStream) (TestMemoryOutputStream): New test cases. svn path=/trunk/; revision=944 --- tests/test_gio.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/test_gio.py b/tests/test_gio.py index 7500e58b..2fb5c3a2 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -545,6 +545,20 @@ class TestInputStream(unittest.TestCase): loop.run() +class TestMemoryInputStream(unittest.TestCase): + def setUp(self): + self.stream = gio.MemoryInputStream() + + def test_add_data(self): + self.stream.add_data('foobar') + self.assertEquals('foobar', self.stream.read()) + + self.stream.add_data('ham ') + self.stream.add_data(None) + self.stream.add_data('spam') + self.assertEquals('ham spam', self.stream.read()) + + class TestOutputStream(unittest.TestCase): def setUp(self): self._f = open("outputstream.txt", "w") @@ -614,6 +628,18 @@ class TestOutputStream(unittest.TestCase): loop.run() +class TestMemoryOutputStream(unittest.TestCase): + def setUp(self): + self.stream = gio.MemoryOutputStream() + + def test_get_contents(self): + self.stream.write('foobar') + self.assertEquals('foobar', self.stream.get_contents()) + + self.stream.write('baz') + self.assertEquals('foobarbaz', self.stream.get_contents()) + + class TestVolumeMonitor(unittest.TestCase): def setUp(self): self.monitor = gio.volume_monitor_get() -- cgit v1.2.1