Пример #1
0
    def test_callback_invoked(self):
        amounts_seen = []

        def callback(amount):
            amounts_seen.append(amount)

        original_stream = six.StringIO('foobarbaz')
        wrapped = StreamReaderProgress(original_stream, callback)
        self.assertEqual(wrapped.read(), 'foobarbaz')
        self.assertEqual(amounts_seen, [9])
Пример #2
0
 def test_proxies_to_wrapped_stream(self):
     original_stream = six.StringIO('foobarbaz')
     wrapped = StreamReaderProgress(original_stream)
     self.assertEqual(wrapped.read(), 'foobarbaz')