cubicweb/test/unittest_binary.py
branch3.26
changeset 12432 2fcb53ee5178
parent 11279 e4f11ef1face
child 12567 26744ad37953
equal deleted inserted replaced
12431:a570191d67b0 12432:2fcb53ee5178
    31     def test_init(self):
    31     def test_init(self):
    32         Binary()
    32         Binary()
    33         Binary(b'toto')
    33         Binary(b'toto')
    34         Binary(bytearray(b'toto'))
    34         Binary(bytearray(b'toto'))
    35         if PY2:
    35         if PY2:
    36             Binary(buffer('toto'))
    36             Binary(buffer('toto'))  # noqa: F821
    37         else:
    37         else:
    38             Binary(memoryview(b'toto'))
    38             Binary(memoryview(b'toto'))
    39         with self.assertRaises((AssertionError, TypeError)):
    39         with self.assertRaises((AssertionError, TypeError)):
    40             # TypeError is raised by BytesIO if python runs with -O
    40             # TypeError is raised by BytesIO if python runs with -O
    41             Binary(u'toto')
    41             Binary(u'toto')
    43     def test_write(self):
    43     def test_write(self):
    44         b = Binary()
    44         b = Binary()
    45         b.write(b'toto')
    45         b.write(b'toto')
    46         b.write(bytearray(b'toto'))
    46         b.write(bytearray(b'toto'))
    47         if PY2:
    47         if PY2:
    48             b.write(buffer('toto'))
    48             b.write(buffer('toto'))  # noqa: F821
    49         else:
    49         else:
    50             b.write(memoryview(b'toto'))
    50             b.write(memoryview(b'toto'))
    51         with self.assertRaises((AssertionError, TypeError)):
    51         with self.assertRaises((AssertionError, TypeError)):
    52             # TypeError is raised by BytesIO if python runs with -O
    52             # TypeError is raised by BytesIO if python runs with -O
    53             b.write(u'toto')
    53             b.write(u'toto')