Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tests for mock, pytest-mock and procrunner #541

Merged
merged 3 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Handlers/test_CommandLine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import pytest
import sys

Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Indexer/test_DIALS_indexer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import sys
Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Indexer/test_XDS_indexer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import sys
Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Indexer/test_XDS_indexer_II.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import sys
Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Integrater/test_DialsIntegrater.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import sys
Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Integrater/test_XDSIntegrater.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import sys
Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Scaler/test_CCP4ScalerA.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

import mock
from unittest import mock
import pathlib
import pytest

Expand Down
2 changes: 1 addition & 1 deletion Test/Modules/Scaler/test_XDSScalerA.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

import mock
from unittest import mock
import pathlib
import pytest

Expand Down
2 changes: 1 addition & 1 deletion Test/Schema/test_XProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys

import mock
from unittest import mock
import pathlib


Expand Down
2 changes: 1 addition & 1 deletion Test/Wrappers/Dials/test_dials_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mock
from unittest import mock
import os
import pytest
import shutil
Expand Down
13 changes: 11 additions & 2 deletions Test/regression/test_delta_cc_half.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from xia2.command_line.delta_cc_half import run
from xia2.Modules.DeltaCcHalf import DeltaCcHalf
import pytest_mock


def test_from_experiments_reflections(dials_data, tmpdir, capsys, mocker):
Expand All @@ -9,7 +10,11 @@ def test_from_experiments_reflections(dials_data, tmpdir, capsys, mocker):
mocker.spy(DeltaCcHalf, "get_table")
with tmpdir.as_cwd():
run(input_files)
assert DeltaCcHalf.get_table.return_value == [
if getattr(pytest_mock, "version", "").startswith("1."):
rv = DeltaCcHalf.get_table.return_value
else:
rv = DeltaCcHalf.get_table.spy_return
assert rv == [
["Dataset", "Batches", "CC½", "ΔCC½", "σ"],
["0", "8 to 1795", " 0.995", " 0.000", "-1.11"],
["3", "5 to 1694", " 0.995", " 0.000", "-0.59"],
Expand All @@ -30,7 +35,11 @@ def test_image_groups_from_unmerged_mtz(dials_data, tmpdir, capsys, mocker):
"group_size=10",
]
)
assert DeltaCcHalf.get_table.return_value == [
if getattr(pytest_mock, "version", "").startswith("1."):
rv = DeltaCcHalf.get_table.return_value
else:
rv = DeltaCcHalf.get_table.spy_return
assert rv == [
["Dataset", "Batches", "CC½", "ΔCC½", "σ"],
["0", "11 to 20", " 0.922", " 0.007", "-0.95"],
["0", "31 to 40", " 0.922", " 0.007", "-0.84"],
Expand Down
2 changes: 1 addition & 1 deletion Test/regression/test_multiple_sweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def test_multiple_sweeps(multi_sweep_type, ccp4, dials_data, run_in_tmpdir):
]
result = procrunner.run(command + [f"image={image}" for image in images])

assert not result["exitcode"] and not result["timeout"]
assert not result.returncode
9 changes: 8 additions & 1 deletion Test/regression/test_multiplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from xia2.command_line.multiplex import run as run_multiplex
from xia2.Modules.MultiCrystal import ScaleAndMerge

import pytest_mock


expected_data_files = [
"scaled.expt",
Expand All @@ -43,7 +45,12 @@ def test_proteinase_k(mocker, regression_test, dials_data, tmpdir):
"completeness_vs_dose",
"rd_vs_batch_difference",
):
assert Report.pychef_plots.return_value[k]["data"][0]["x"] == list(range(26))
if getattr(pytest_mock, "version", "").startswith("1."):
assert Report.pychef_plots.return_value[k]["data"][0]["x"] == list(
range(26)
)
else:
assert Report.pychef_plots.spy_return[k]["data"][0]["x"] == list(range(26))
for f in expected_data_files:
assert tmpdir.join(f).check(file=1), "expected file %s missing" % f
multiplex_expts = load.experiment_list(
Expand Down
3 changes: 1 addition & 2 deletions libtbx_config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"python_required": [
"dials-data>=2.0",
"Jinja2",
"mock>=2.0",
"procrunner",
"pytest>=3.1",
"pytest-mock>=1.11,<2",
"pytest-mock",
"tabulate",
],
}
1 change: 1 addition & 0 deletions newsfragments/541.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support pytest-mock versions >1, drop dependency on mock package