-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make apply-mocks fixture usable by all tests. Start hooks and fixture…
…s modules for pytest, loaded using conftest.py in the script tests directory.
- Loading branch information
1 parent
31d34ca
commit 7566bcf
Showing
7 changed files
with
95 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import numpy as np | ||
|
||
|
||
def assert_images_close(img1, img2): | ||
dtype = img1.header.get_data_dtype() | ||
|
||
assert np.allclose(img1.affine, img2.affine), "Images affines don't match" | ||
|
||
assert np.allclose( | ||
img1.get_fdata(dtype=dtype), img2.get_fdata(dtype=dtype)), \ | ||
"Images data don't match. MSE : {} | max SE : {}".format( | ||
np.mean((img1.get_fdata(dtype=dtype) - | ||
img2.get_fdata(dtype=dtype)) ** 2.), | ||
np.max((img1.get_fdata(dtype=dtype) - | ||
img2.get_fdata(dtype=dtype)) ** 2.)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def apply_mocks(request): | ||
return request.config.getoption("--apply-mocks") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--apply-mocks", | ||
action="store_true", | ||
help="Apply mocks to accelerate tests and " | ||
"prevent testing external dependencies" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pytest | ||
|
||
pytest_plugins = [ | ||
"scilpy.tests.fixtures", | ||
"scilpy.tests.hooks" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters