コード例 #1
0
ファイル: test_base.py プロジェクト: tcmlabs/pymedphys
def test_equal():
    dicom1 = DicomBase.from_dict({
        'Manufacturer': 'PyMedPhys',
        'PatientName': 'Python^Monte'
    })
    dicom2 = DicomBase.from_dict({
        'Manufacturer': 'PyMedPhys',
        'PatientName': 'Python^Monte'
    })
    assert dicom1 == dicom2  # Equality from dict

    try:
        fp1 = DicomBytesIO()
        dicom1.to_file(fp1)
        fp2 = DicomBytesIO()
        dicom2.to_file(fp2)

        dicom1_from_file = DicomBase.from_file(fp1)
        dicom2_from_file = DicomBase.from_file(fp2)
        # Equality from file (implicitly also from dataset)
        assert dicom1_from_file == dicom2_from_file

        dicom1_from_file.dataset.PatientName = 'test^PatientName change'
        assert dicom1_from_file != dicom2_from_file  # Negative case

        dicom1_from_file.dataset.PatientName = 'Python^Monte'
        assert dicom1_from_file == dicom2_from_file  # Equality post re-assignment

        dicom1_from_file_copied = deepcopy(dicom1_from_file)
        assert dicom1_from_file == dicom1_from_file_copied  # Equality from deepcopy
    finally:
        fp1.close()
        fp2.close()
コード例 #2
0
ファイル: test_base.py プロジェクト: tcmlabs/pymedphys
def test_to_and_from_file():
    temp_file = io.BytesIO()

    dicom = DicomBase.from_dict({
        'Manufacturer': 'PyMedPhys',
        'PatientName': 'Python^Monte'
    })

    dicom.to_file(temp_file)

    new_dicom = DicomBase.from_file(temp_file)

    # TODO: Without the str this was passing locally but not on CI. Further
    # investigation needed.
    assert new_dicom == dicom