File: test_vr.py

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (31 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (4)
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()