|
21 | 21 | from pydicom import dcmread
|
22 | 22 | from pydicom.dataset import Dataset, FileMetaDataset
|
23 | 23 | from pydicom.uid import (
|
| 24 | + generate_uid, |
24 | 25 | ImplicitVRLittleEndian,
|
25 | 26 | ExplicitVRLittleEndian,
|
26 | 27 | JPEGBaseline8Bit,
|
@@ -1876,51 +1877,49 @@ def handle_store(event):
|
1876 | 1877 | ae.add_requested_context(CTImageStorage, ImplicitVRLittleEndian)
|
1877 | 1878 | ae.add_requested_context(CTImageStorage, ExplicitVRBigEndian)
|
1878 | 1879 | assoc = ae.associate("localhost", 11112)
|
1879 |
| - |
1880 | 1880 | assert assoc.is_established
|
1881 |
| - ds = dcmread(DATASET_PATH) |
1882 |
| - assert ds.is_little_endian |
1883 |
| - assert not ds.is_implicit_VR |
1884 |
| - assert ds.file_meta.TransferSyntaxUID == ExplicitVRLittleEndian |
1885 |
| - |
1886 |
| - is_implicit_vr_warning = ( |
1887 |
| - "'FileDataset.is_implicit_VR' will be removed in v4.0, set the " |
1888 |
| - "Transfer Syntax UID or use the 'implicit_vr' argument with " |
1889 |
| - r"FileDataset.save_as\(\) or dcmwrite\(\) instead" |
1890 |
| - ) |
1891 |
| - |
1892 |
| - is_little_endian_warning = ( |
1893 |
| - "'FileDataset.is_little_endian' will be removed in v4.0, set the " |
1894 |
| - "Transfer Syntax UID or use the 'little_endian' argument with " |
1895 |
| - r"FileDataset.save_as\(\) or dcmwrite\(\) instead" |
1896 |
| - ) |
1897 |
| - |
1898 |
| - with pytest.warns(DeprecationWarning, match=is_implicit_vr_warning): |
1899 |
| - ds.is_implicit_VR = True |
1900 | 1881 |
|
1901 |
| - status = assoc.send_c_store(ds) |
1902 |
| - assert status.Status == 0x0000 |
1903 |
| - |
1904 |
| - with pytest.warns(DeprecationWarning, match=is_implicit_vr_warning): |
1905 |
| - ds.is_implicit_VR = False |
1906 |
| - with pytest.warns(DeprecationWarning, match=is_little_endian_warning): |
1907 |
| - ds.is_little_endian = False |
| 1882 | + ds = Dataset() |
| 1883 | + ds.SOPClassUID = CTImageStorage |
| 1884 | + ds.SOPInstanceUID = generate_uid() |
| 1885 | + file_meta = FileMetaDataset() |
| 1886 | + file_meta.TransferSyntaxUID = ExplicitVRLittleEndian |
| 1887 | + ds.file_meta = file_meta |
| 1888 | + |
| 1889 | + with caplog.at_level(logging.WARNING, logger="pynetdicom"): |
| 1890 | + with pytest.warns(DeprecationWarning): |
| 1891 | + ds.is_implicit_VR = True |
| 1892 | + ds.is_little_endian = True |
| 1893 | + status = assoc.send_c_store(ds) |
| 1894 | + assert status.Status == 0x0000 |
1908 | 1895 |
|
1909 |
| - status = assoc.send_c_store(ds) |
1910 |
| - assert status.Status == 0x0000 |
| 1896 | + with pytest.warns(DeprecationWarning): |
| 1897 | + ds.is_implicit_VR = False |
| 1898 | + ds.is_little_endian = False |
| 1899 | + status = assoc.send_c_store(ds) |
| 1900 | + assert status.Status == 0x0000 |
1911 | 1901 |
|
1912 |
| - with pytest.warns(DeprecationWarning, match=is_implicit_vr_warning): |
| 1902 | + assert ( |
| 1903 | + "'dataset' is encoded as implicit VR little endian but the file " |
| 1904 | + "meta has a (0002,0010) Transfer Syntax UID of 'Explicit VR " |
| 1905 | + "Little Endian' - using 'Implicit VR Little Endian' instead" |
| 1906 | + ) in caplog.text |
| 1907 | + assert ( |
| 1908 | + "'dataset' is encoded as explicit VR big endian but the file " |
| 1909 | + "meta has a (0002,0010) Transfer Syntax UID of 'Explicit VR " |
| 1910 | + "Little Endian' - using 'Explicit VR Big Endian' instead" |
| 1911 | + ) in caplog.text |
| 1912 | + |
| 1913 | + with pytest.warns(DeprecationWarning): |
1913 | 1914 | ds.is_implicit_VR = False
|
1914 |
| - with pytest.warns(DeprecationWarning, match=is_little_endian_warning): |
1915 | 1915 | ds.is_little_endian = True
|
1916 | 1916 | ds.file_meta.TransferSyntaxUID = ImplicitVRLittleEndian
|
1917 |
| - |
1918 |
| - encoding_mismatch_msg = ( |
| 1917 | + msg = ( |
1919 | 1918 | "'dataset' is encoded as explicit VR little endian but the file "
|
1920 | 1919 | r"meta has a \(0002,0010\) Transfer Syntax UID of 'Implicit VR "
|
1921 | 1920 | "Little Endian' - please set an appropriate Transfer Syntax"
|
1922 | 1921 | )
|
1923 |
| - with pytest.raises(AttributeError, match=encoding_mismatch_msg): |
| 1922 | + with pytest.raises(AttributeError, match=msg): |
1924 | 1923 | status = assoc.send_c_store(ds)
|
1925 | 1924 |
|
1926 | 1925 | assoc.release()
|
|
0 commit comments