當前位置: 首頁>>代碼示例>>Python>>正文


Python primitives.Base類代碼示例

本文整理匯總了Python中kmip.core.primitives.Base的典型用法代碼示例。如果您正苦於以下問題:Python Base類的具體用法?Python Base怎麽用?Python Base使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Base類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_read

    def test_read(self):
        self.stream.write(b'\x42\x00\x00\x00\x00\x00\x00\x04')
        base = Base()
        base.length = 4

        # Check no exception thrown
        base.read(self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:7,代碼來源:test_primitives.py

示例2: test_read_tag

    def test_read_tag(self):
        encoding = (b'\x42\x00\x00')
        base = Base()
        self.stream = BytearrayStream(encoding)

        # Check no exception thrown
        base.read_tag(self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:7,代碼來源:test_primitives.py

示例3: test_read_length_overflow

    def test_read_length_overflow(self):
        self.stream.write(b'\x00\x00\x00\x04\x00')
        base = Base()
        base.length = 4

        # Check no exception thrown
        base.read_length(self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:7,代碼來源:test_primitives.py

示例4: test_read_length_underflow

    def test_read_length_underflow(self):
        self.stream.write(b'\x00')
        base = Base()
        base.length = 4

        self.assertRaises(errors.ReadValueError, base.read_length,
                          self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:7,代碼來源:test_primitives.py

示例5: test_write_type

    def test_write_type(self):
        encoding = b'\x00'
        base = Base()
        base.write_type(self.stream)

        result = self.stream.read()
        len_exp = len(encoding)
        len_rcv = len(result)

        self.assertEqual(len_exp, len_rcv,
                         self.bad_write.format('type',
                                               '{0} bytes'.format(len_exp),
                                               '{0} bytes'.format(len_rcv)))
        self.assertEqual(encoding, result, self.bad_encoding.format('type'))
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:14,代碼來源:test_primitives.py

示例6: test_is_tag_next_invalid

    def test_is_tag_next_invalid(self):
        encoding = (b'\x42\x00\x01')
        base = Base()
        self.stream = BytearrayStream(encoding)

        self.assertFalse(Base.is_tag_next(base.tag, self.stream),
                         self.bad_match.format('tag', 'mismatch', 'match'))
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:7,代碼來源:test_primitives.py

示例7: process

    def process(self, istream, ostream):
        stream = istream.read()

        if Base.is_tag_next(Tags.REQUEST_MESSAGE, stream):
            message = RequestMessage()
            message.read(stream)
            try:
                result = self._process_request(message)
            except Exception as e:
                raise e
            tstream = BytearrayStream()
            result.write(tstream)
            ostream.write(tstream.buffer)
        elif Base.is_tag_next(Tags.RESPONSE_MESSAGE, stream):
            message = ResponseMessage()
            message.read(stream)
            self._process_response(message)
        else:
            raise ValueError('Processing error: stream contains unknown '
                             'message type')
開發者ID:wyllys66,項目名稱:PyKMIP,代碼行數:20,代碼來源:processor.py

示例8: test_read_type

    def test_read_type(self):
        self.stream.write(b'\x00')
        base = Base()

        # Check no exception thrown
        base.read_type(self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:6,代碼來源:test_primitives.py

示例9: test_is_oversized

    def test_is_oversized(self):
        base = Base()

        # Check no exception thrown
        base.is_oversized(self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:5,代碼來源:test_primitives.py

示例10: test_write_length_invalid

    def test_write_length_invalid(self):
        base = Base()
        base.length = ''

        self.assertRaises(TypeError, base.write_length, self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:5,代碼來源:test_primitives.py

示例11: test_write_type_invalid

    def test_write_type_invalid(self):
        base = Base()
        base.type = ''

        self.assertRaises(TypeError, base.write_type, self.stream)
開發者ID:callidus,項目名稱:PyKMIP,代碼行數:5,代碼來源:test_primitives.py


注:本文中的kmip.core.primitives.Base類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。