예제 #1
0
class TestStaticField(unittest.TestCase):

    def setUp(self):
        self.sf = StaticField("staticfield", 2)

    def test_trivial(self):
        pass

    def test_parse(self):
        self.assertEqual(self.sf.parse(six.b("ab")), six.b("ab"))

    def test_build(self):
        self.assertEqual(self.sf.build(six.b("ab")), six.b("ab"))

    def test_parse_too_short(self):
        self.assertRaises(FieldError, self.sf.parse, six.b("a"))

    def test_build_too_short(self):
        self.assertRaises(FieldError, self.sf.build, six.b("a"))

    def test_sizeof(self):
        self.assertEqual(self.sf.sizeof(), 2)

    def test_field_parse(self):
        f = Field('name', 6)
        self.assertEqual(f.parse(six.b('abcdef')), six.b('abcdef'))
        self.assertEqual(f.parse(six.b('12abcdef')), six.b('12abcd'))
예제 #2
0
class TestStaticField(unittest.TestCase):
    def setUp(self):
        self.sf = StaticField("staticfield", 2)

    def test_trivial(self):
        pass

    def test_parse(self):
        self.assertEqual(self.sf.parse(b"ab"), b"ab")

    def test_build(self):
        self.assertEqual(self.sf.build(b"ab"), b"ab")

    def test_parse_too_short(self):
        self.assertRaises(FieldError, self.sf.parse, b"a")

    def test_build_too_short(self):
        self.assertRaises(FieldError, self.sf.build, b"a")

    def test_sizeof(self):
        self.assertEqual(self.sf.sizeof(), 2)

    def test_field_parse(self):
        f = Field("name", 6)
        self.assertEqual(f.parse(b"abcdef"), b"abcdef")
        self.assertEqual(f.parse(b"12abcdef"), b"12abcd")
예제 #3
0
class TestStaticField(unittest.TestCase):
    def setUp(self):
        self.sf = StaticField("staticfield", 2)

    def test_trivial(self):
        pass

    def test_parse(self):
        self.assertEqual(self.sf.parse(b"ab"), b"ab")

    def test_build(self):
        self.assertEqual(self.sf.build(b"ab"), b"ab")

    def test_parse_too_short(self):
        self.assertRaises(FieldError, self.sf.parse, b"a")

    def test_build_too_short(self):
        self.assertRaises(FieldError, self.sf.build, b"a")

    def test_sizeof(self):
        self.assertEqual(self.sf.sizeof(), 2)

    def test_field_parse(self):
        f = Field('name', 6)
        self.assertEqual(f.parse(b'abcdef'), b'abcdef')
        self.assertEqual(f.parse(b'12abcdef'), b'12abcd')
예제 #4
0
파일: test_core.py 프로젝트: MacLeek/mh
class TestStaticField(unittest.TestCase):
    def setUp(self):
        self.sf = StaticField("staticfield", 2)

    def test_trivial(self):
        pass

    def test_parse(self):
        self.assertEqual(self.sf.parse("ab"), "ab")

    def test_build(self):
        self.assertEqual(self.sf.build("ab"), "ab")

    def test_parse_too_short(self):
        self.assertRaises(FieldError, self.sf.parse, "a")

    def test_build_too_short(self):
        self.assertRaises(FieldError, self.sf.build, "a")

    def test_sizeof(self):
        self.assertEqual(self.sf.sizeof(), 2)
예제 #5
0
파일: test_core.py 프로젝트: MacLeek/mh
class TestStaticField(unittest.TestCase):

    def setUp(self):
        self.sf = StaticField("staticfield", 2)

    def test_trivial(self):
        pass

    def test_parse(self):
        self.assertEqual(self.sf.parse("ab"), "ab")

    def test_build(self):
        self.assertEqual(self.sf.build("ab"), "ab")

    def test_parse_too_short(self):
        self.assertRaises(FieldError, self.sf.parse, "a")

    def test_build_too_short(self):
        self.assertRaises(FieldError, self.sf.build, "a")

    def test_sizeof(self):
        self.assertEqual(self.sf.sizeof(), 2)