Esempio n. 1
0
def test_stdout(dcm_16x16_le_path, capfdbinary):
    src_path = dcm_16x16_le_path

    with slice_context(src_path, "-"):
        pass

    captured = capfdbinary.readouterr()
    slice_proxy = io.read(BytesIO(captured.out))
    assert slice_proxy.width == 16
    assert slice_proxy.height == 16
Esempio n. 2
0
def test_convert_format(test_convert_format_context):
    src_path, dst_path, expect_dst_path, params = test_convert_format_context
    expect_pixels = np.arange(100).reshape(10, 10).astype(np.uint8)

    with slice_context(src_path, dst_path, params) as proxy:
        assert proxy.width == 16
        assert proxy.height == 16
        proxy.pixels = expect_pixels

    assert os.path.exists(expect_dst_path)
    with open(expect_dst_path, "rb") as dst_fo:
        result = io.read(dst_fo)
        assert result.width == 10
        assert result.height == 10
        assert np.allclose(result.pixels, expect_pixels, atol=1)
Esempio n. 3
0
def test_attr_override(test_attr_override_context):
    src_path, dst_path, expect_params = test_attr_override_context

    with slice_context(src_path, dst_path, expect_params) as proxy:
        assert np.allclose(proxy.spacing, expect_params["proxy"]["spacing"])
        assert np.allclose(proxy.origin, expect_params["proxy"]["origin"])
        assert np.allclose(proxy.orientation,
                           expect_params["proxy"]["orientation"])

    assert os.path.exists(dst_path)
    with open(dst_path, "rb") as dst_fo:
        result = io.read(dst_fo)
        assert np.allclose(result.spacing, expect_params["proxy"]["spacing"])
        assert np.allclose(result.origin, expect_params["proxy"]["origin"])
        assert np.allclose(result.orientation,
                           expect_params["proxy"]["orientation"])
        assert result.Modality == expect_params["proxy"]["Modality"]
Esempio n. 4
0
def test_only_src(dcm_16x16_le_path):
    src_path = dcm_16x16_le_path

    with slice_context(src_path, None) as proxy:
        assert proxy.width == 16
        assert proxy.height == 16
Esempio n. 5
0
def test_stdin(dcm_16x16_le_fo, monkeypatch):
    monkeypatch.setattr("sys.stdin", dcm_16x16_le_fo)

    with slice_context("-", None) as proxy:
        assert proxy.width == 16
        assert proxy.height == 16