1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
import pickle
import unittest
import odil
class TestVR(unittest.TestCase):
def test_bytes_constructor(self):
vr = odil.VR(b"UT")
self.assertEqual(vr, odil.VR.UT)
def test_unicode_constructor(self):
vr = odil.VR(u"UT")
self.assertEqual(vr, odil.VR.UT)
def test_invalid_bytes_constructor(self):
with self.assertRaises(Exception):
odil.VR(b"XX")
def test_invalid_unicode_constructor(self):
with self.assertRaises(Exception):
odil.VR(u"XX")
def test_string(self):
vr = odil.VR.AE
self.assertEqual(str(vr), "AE")
def test_pickle(self):
self.assertEqual(pickle.loads(pickle.dumps(odil.VR.AE)), odil.VR.AE)
if __name__ == "__main__":
unittest.main()
|