Пример #1
0
    def test_begin_exception(self):
        stream = ParserStream()

        def exception_func():
            raise Exception()

        stream._ParserStream__prepare_descriptor = exception_func
        self.assertRaises(Exception, stream.begin)
Пример #2
0
    def test_begin_exception(self):
        stream = ParserStream()

        def exception_func():
            raise Exception()

        stream._ParserStream__prepare_descriptor = exception_func
        self.assertRaises(Exception, stream.begin)
Пример #3
0
    def test_process_data(self):
        stream = ParserStream()

        class TestFile(object):
            def read(self):
                return 'test data'

        stream._ParserStream__out = TestFile()
        stream.process()
Пример #4
0
    def test_process_exception(self):
        stream = ParserStream()

        class ExceptionFile(object):
            def read(self):
                raise IOError(errno.EIO, 'Test error')

        stream._ParserStream__out = ExceptionFile()
        self.assertRaises(Exception, stream.process)
Пример #5
0
    def test_process_exception(self):
        stream = ParserStream()

        class ExceptionFile(object):
            def read(self):
                raise IOError(errno.EIO, 'Test error')

        stream._ParserStream__out = ExceptionFile()
        self.assertRaises(Exception, stream.process)
Пример #6
0
    def test_process_data(self):
        stream = ParserStream()

        class TestFile(object):
            def read(self):
                return 'test data'

        stream._ParserStream__out = TestFile()
        stream.process()
Пример #7
0
    def test_parse(self):
        class TestParser(Base):
            def __init__(self):
                super(TestParser, self).__init__(self.__parse)

            def __parse(self, data):
                return self.__parse

        stream = ParserStream(TestParser())
        stream.parse()
Пример #8
0
    def test_parse(self):
        class TestParser(Base):
            def __init__(self):
                super(TestParser, self).__init__(self.__parse)

            def __parse(self, data):
                return self.__parse

        stream = ParserStream(TestParser())
        stream.parse()
Пример #9
0
 def test_process(self):
     stream = ParserStream()
     descriptor = stream.begin()
     stream.process()
Пример #10
0
 def test_clean(self):
     stream = ParserStream()
     stream.begin()
     stream.clean()
Пример #11
0
 def test_begin_twice(self):
     stream = ParserStream()
     descriptor = stream.begin()
     self.assertEqual(stream.begin(), descriptor)
Пример #12
0
 def test_begin(self):
     stream = ParserStream()
     write_descriptor, read_descriptor = stream.begin()
     self.assertTrue(isinstance(write_descriptor, (int, long)))
     self.assertTrue(isinstance(read_descriptor, (int, long)))
Пример #13
0
 def test_process(self):
     stream = ParserStream()
     descriptor = stream.begin()
     stream.process()
Пример #14
0
 def test_clean(self):
     stream = ParserStream()
     stream.begin()
     stream.clean()
Пример #15
0
 def test_begin_twice(self):
     stream = ParserStream()
     descriptor = stream.begin()
     self.assertEqual(stream.begin(), descriptor)
Пример #16
0
 def test_creation(self):
     ParserStream()
Пример #17
0
 def test_begin(self):
     stream = ParserStream()
     write_descriptor, read_descriptor = stream.begin()
     self.assertTrue(isinstance(write_descriptor, (int, long)))
     self.assertTrue(isinstance(read_descriptor, (int, long)))