|
1 | 1 | import os |
2 | 2 | import shutil |
3 | 3 | from pathlib import Path |
| 4 | +from unittest.mock import Mock |
4 | 5 |
|
5 | | -import numpy as np |
6 | 6 | import pytest |
7 | 7 |
|
8 | 8 | from diffpy.srxplanar.loadimage import LoadImage |
@@ -33,24 +33,23 @@ def test_load_image(file_name, user_filesystem): |
33 | 33 | # These values were obtained from docs/examples/data/KFe2As2-00838.tif |
34 | 34 | expected_mean = 2595.7087 |
35 | 35 | expected_shape = (2048, 2048) |
36 | | - expected_first_point = ? |
37 | | - expected_last_point = ? |
| 36 | + expected_first_point = 0 |
| 37 | + expected_last_point = 0 |
38 | 38 |
|
39 | 39 | # locate source example file inside project docs |
40 | | - source_file = PROJECT_ROOT / "docs" / "examples" / "data" / "KFe2As2-00838.tif" |
| 40 | + source_file = ( |
| 41 | + PROJECT_ROOT / "docs" / "examples" / "data" / "KFe2As2-00838.tif" |
| 42 | + ) |
41 | 43 | shutil.copy(source_file, cwd_dir / "KFe2As2-00838.tif") |
42 | 44 | shutil.copy(source_file, home_dir / "KFe2As2-00838.tif") |
43 | 45 |
|
44 | 46 | try: |
45 | | - cfg = type( |
46 | | - "Cfg", (), {"fliphorizontal": False, "flipvertical": False} |
47 | | - )() |
48 | | - loader = LoadImage(cfg) |
| 47 | + loader = LoadImage(Mock(fliphorizontal=False, flipvertical=False)) |
49 | 48 | actual = loader.load_image(file_name) |
50 | 49 | assert actual.shape == expected_shape |
51 | 50 | assert actual.mean() == expected_mean |
52 | | - assert actual[0] == expected_first_point |
53 | | - assert actual[-1] == expected_last_point |
| 51 | + assert actual[0][0] == expected_first_point |
| 52 | + assert actual[-1][-1] == expected_last_point |
54 | 53 | except FileNotFoundError: |
55 | 54 | pytest.raises( |
56 | 55 | FileNotFoundError, |
|
0 commit comments