def test_encoding_carried(self):
     """Test encoding is carried over to a new PN3 object"""
     # Issue 466
     from pydicom.valuerep import PersonName3
     pn = PersonName3("John^Doe", encodings='iso_ir_126')
     assert pn.encodings == ('iso_ir_126',)
     pn2 = PersonName3(pn)
     assert pn2.encodings == ('iso_ir_126',)
Beispiel #2
0
 def testNotEqual(self):
     """PN3: Not equal works correctly (issue 121)..."""
     # Meant to only be used in python 3 but doing simple check here
     from pydicom.valuerep import PersonName3
     pn = PersonName3("John^Doe")
     msg = "PersonName3 not equal comparison did not work correctly"
     self.assertFalse(pn != "John^Doe", msg)
Beispiel #3
0
    def test_japanese_multi_byte_personname(self):
        """Test japanese person name which has multi byte strings are
        correctly encoded."""
        file_path = get_charset_files('chrH32.dcm')[0]
        ds = dcmread(file_path)
        ds.decode()

        if hasattr(ds.PatientName, 'original_string'):
            original_string = ds.PatientName.original_string
            ds.PatientName.original_string = None
            fp = DicomBytesIO()
            fp.is_implicit_VR = False
            fp.is_little_endian = True
            ds.save_as(fp, write_like_original=False)
            fp.seek(0)
            ds_out = dcmread(fp)
            assert original_string == ds_out.PatientName.original_string

        japanese_pn = PersonName3(u"Mori^Ogai=森^鷗外=もり^おうがい")
        pyencs = pydicom.charset.convert_encodings(
            ["ISO 2022 IR 6", "ISO 2022 IR 87", "ISO 2022 IR 159"])
        actual_encoded = bytes(japanese_pn.encode(pyencs))
        expect_encoded = (
            b"\x4d\x6f\x72\x69\x5e\x4f\x67\x61\x69\x3d\x1b\x24\x42\x3f"
            b"\x39\x1b\x28\x42\x5e\x1b\x24\x28\x44\x6c\x3f\x1b\x24\x42"
            b"\x33\x30\x1b\x28\x42\x3d\x1b\x24\x42\x24\x62\x24\x6a\x1b"
            b"\x28\x42\x5e\x1b\x24\x42\x24\x2a\x24\x26\x24\x2c\x24\x24"
            b"\x1b\x28\x42")
        assert expect_encoded == actual_encoded
 def test_not_equal(self):
     """PN3: Not equal works correctly (issue 121)..."""
     # Meant to only be used in python 3 but doing simple check here
     from pydicom.valuerep import PersonName3
     pn = PersonName3("John^Doe")
     assert not pn != "John^Doe"