Skip to content

Commit

Permalink
Apply black to test files
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter2206 committed Nov 29, 2023
1 parent 0999128 commit 0bb77e9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
9 changes: 7 additions & 2 deletions tests/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ def test_command_line_interface_accepts_common_and_solver_arguments(tmp_path):

df = pd.read_csv(output_file)
print(df)
assert df.shape == (13, 6) # 6 = 4 vars + one column for energy and one for num_occurrences
np.testing.assert_array_equal(df.columns, ["0", "1", "2", "3", "energy", "num_occurrences"])
assert df.shape == (
13,
6,
) # 6 = 4 vars + one column for energy and one for num_occurrences
np.testing.assert_array_equal(
df.columns, ["0", "1", "2", "3", "energy", "num_occurrences"]
)
32 changes: 26 additions & 6 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ def test_filtering_namespace_by_iterable_extracts_only_attributes_with_names_fro
"default": 0.5,
},
"--prob",
{"help": "probability of choosing 1 (default 0.5)", "type": float, "default": 0.5},
{
"help": "probability of choosing 1 (default 0.5)",
"type": float,
"default": 0.5,
},
),
(
{"name": "num_reads", "help": "number of samples to draw", "type": "int", "default": 1},
{
"name": "num_reads",
"help": "number of samples to draw",
"type": "int",
"default": 1,
},
"--num_reads",
{"help": "number of samples to draw", "type": int, "default": 1},
),
Expand All @@ -61,15 +70,19 @@ def test_adding_argument_from_specification_to_parser_populates_all_fields_prese
parser.add_argument.assert_called_once_with(expected_name, **expected_kwargs)


def test_when_importing_object_by_dotted_path_loader_is_called_with_modules_path(mocker):
def test_when_importing_object_by_dotted_path_loader_is_called_with_modules_path(
mocker,
):
loader = mocker.create_autospec(importlib.import_module)

import_object("omnisolver.pkg.my_sampler.CustomSampler", loader)

loader.assert_called_once_with("omnisolver.pkg.my_sampler")


def test_importing_object_by_dotted_path_the_object_retrieves_it_from_imported_module(mocker):
def test_importing_object_by_dotted_path_the_object_retrieves_it_from_imported_module(
mocker,
):
loader = mocker.create_autospec(importlib.import_module)
loader.return_value.CustomSampler = type("CustomSampler", tuple(), {})

Expand All @@ -93,7 +106,12 @@ class TestCreatingPluginFromSchema:
}
],
"sample_args": [
{"name": "num_reads", "help": "number of samples to draw", "type": "int", "default": 1},
{
"name": "num_reads",
"help": "number of samples to draw",
"type": "int",
"default": 1,
},
],
}

Expand Down Expand Up @@ -138,7 +156,9 @@ def test_gives_plugin_with_populate_parser_that_adds_all_arguments_from_specific
type=float,
default=0.5,
),
mocker.call("--num_reads", help="number of samples to draw", type=int, default=1),
mocker.call(
"--num_reads", help="number of samples to draw", type=int, default=1
),
],
any_order=False,
)
Expand Down

0 comments on commit 0bb77e9

Please sign in to comment.