diff --git a/tests/molecular/molecules/building_block/conftest.py b/tests/molecular/molecules/building_block/conftest.py index d1f290e07..a2b6c894d 100644 --- a/tests/molecular/molecules/building_block/conftest.py +++ b/tests/molecular/molecules/building_block/conftest.py @@ -29,7 +29,7 @@ def case_data(request) -> CaseData: @pytest.fixture -def building_block(case_data): +def building_block(case_data: CaseData) -> stk.BuildingBlock: """ A :class:`.BuildingBlock` instance. @@ -50,18 +50,17 @@ def building_block(case_data): ), ) ) -def get_functional_groups(request): +def get_functional_groups( + request: pytest.FixtureRequest, +) -> stk.FunctionalGroup: """ - Yield the functional groups of a `molecule`. + Get the functional groups of a `molecule`. - Parameters - ---------- - molecule : :class:`.Molecule` - The molecule whose functional groups should be gotten. + Parameters: + molecule: + The molecule whose functional groups should be gotten. - Yields - ------ - :class:`.FunctionalGroup` + Returns: A functional group of `molecule`. """ diff --git a/tests/molecular/molecules/building_block/fixtures/init_from_file.py b/tests/molecular/molecules/building_block/fixtures/init_from_file.py index 606d0be86..f15cf53ba 100644 --- a/tests/molecular/molecules/building_block/fixtures/init_from_file.py +++ b/tests/molecular/molecules/building_block/fixtures/init_from_file.py @@ -1,13 +1,11 @@ import pytest import stk - +from collections.abc import Iterable from ..case_data import CaseData @pytest.fixture( - params=[ - "building_block.mol", - ], + params=["building_block.mol"], ) def path(tmpdir, request): return tmpdir / request.param @@ -17,78 +15,76 @@ class InitFromFileData: """ Stores data for the :meth:`.BuildingBlock.init_from_file`. - Attributes - ---------- - building_block : :class:`.BuildingBlock` - The building block, which will be written to a file, so that it - can be initialized from it. + Attributes: + building_block: + The building block, which will be written to a file, so + that it can be initialized from it. - init_functional_groups : :class:`iterable` - Passed to the `functional_groups` parameter of - :meth:`.BuildingBlock.init_from_file`. + init_functional_groups: + Passed to the `functional_groups` parameter of + :meth:`.BuildingBlock.init_from_file`. - init_placer_ids : :class:`tuple` or :class:`NoneType` - Passed to the `placer_ids` parameter of - :meth:`.BuildingBlock.init_from_file`. + init_placer_ids: + Passed to the `placer_ids` parameter of + :meth:`.BuildingBlock.init_from_file`. - case_data_functional_groups : :class:`tuple` - The functional groups the initialized building block should - have. + case_data_functional_groups: + The functional groups the initialized building block should + have. - case_data_core_atom_ids : :class:`tuple` of :class:`int` - The ids of core atoms the initialized building block should - have. + case_data_core_atom_ids: + The ids of core atoms the initialized building block should + have. - case_data_placer_ids : :class:`tuple` of :class:`int` - The ids of *placer* atoms the initialized building block should - have. + case_data_placer_ids: : :class:`tuple` of :class:`int` + The ids of *placer* atoms the initialized building block + should have. - known_repr : str - The representation of the building block. + known_repr: + The representation of the building block. """ def __init__( self, - building_block, - init_functional_groups, - init_placer_ids, - case_data_functional_groups, - case_data_core_atom_ids, - case_data_placer_ids, - known_repr, - ): + building_block: stk.BuildingBlock, + init_functional_groups: Iterable, + init_placer_ids: tuple | None, + case_data_functional_groups: tuple, + case_data_core_atom_ids: tuple[int, ...], + case_data_placer_ids: tuple[int, ...], + known_repr: str, + ) -> None: """ Initialize a :class:`.InitFromData` instance. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block, which will be written to a file, so - that it can be initialized from it. + Parameters: + building_block: + The building block, which will be written to a file, so + that it can be initialized from it. - init_functional_groups : :class:`iterable` - Passed to the `functional_groups` parameter of - :meth:`.BuildingBlock.init_from_file`. + init_functional_groups: + Passed to the `functional_groups` parameter of + :meth:`.BuildingBlock.init_from_file`. - init_placer_ids : :class:`tuple` or :class:`NoneType` - Passed to the `placer_ids` parameter of - :meth:`.BuildingBlock.init_from_file`. + init_placer_ids: + Passed to the `placer_ids` parameter of + :meth:`.BuildingBlock.init_from_file`. - case_data_functional_groups : :class:`tuple` - The functional groups the initialized building block should - have. + case_data_functional_groups: + The functional groups the initialized building block should + have. - case_data_core_atom_ids : :class:`tuple` of :class:`int` - The ids of core atoms the initialized building block should - have. + case_data_core_atom_ids: + The ids of core atoms the initialized building block should + have. - case_data_placer_ids : :class:`tuple` of :class:`int` - The ids of *placer* atoms the initialized building block - should have. + case_data_placer_ids: : :class:`tuple` of :class:`int` + The ids of *placer* atoms the initialized building block + should have. - known_repr : str - The representation of the building block. + known_repr: + The representation of the building block. """ diff --git a/tests/molecular/molecules/building_block/test_get_core_atom_ids.py b/tests/molecular/molecules/building_block/test_get_core_atom_ids.py index c8b28cb64..76ff857be 100644 --- a/tests/molecular/molecules/building_block/test_get_core_atom_ids.py +++ b/tests/molecular/molecules/building_block/test_get_core_atom_ids.py @@ -1,19 +1,19 @@ import itertools as it +from .case_data import CaseData -def test_get_core_atom_ids(case_data): + +def test_get_core_atom_ids(case_data: CaseData) -> None: """ Test :meth:`.BuildingBlock.get_core_atom_ids`. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. Holds the building block to test and the correct - core atom ids. + Parameters: + case_data: + A test case. Holds the building block to test and the correct + core atom ids. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/molecules/building_block/test_get_functional_groups.py b/tests/molecular/molecules/building_block/test_get_functional_groups.py index c6dd4e86e..b429fc754 100644 --- a/tests/molecular/molecules/building_block/test_get_functional_groups.py +++ b/tests/molecular/molecules/building_block/test_get_functional_groups.py @@ -2,20 +2,21 @@ from ..utilities import is_equivalent_functional_group +import stk +from .case_data import CaseData -def test_get_functional_groups(case_data): + +def test_get_functional_groups(case_data: CaseData) -> None: """ Test :meth:`.BuildingBlock.get_functional_groups`. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. Holds the building block to test and the correct - functional groups. + Parameters: + case_data: + A test case. Holds the building block to test and the correct + functional groups. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -25,21 +26,22 @@ def test_get_functional_groups(case_data): ) -def _test_get_functional_groups(building_block, functional_groups): +def _test_get_functional_groups( + building_block: stk.BuildingBlock, + functional_groups: tuple[stk.FunctionalGroup], +) -> None: """ Test :meth:`.BuildingBlock.get_functional_groups`. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block to test. + Parameters: + building_block: + The building block to test. - functional_groups : :class:`tuple` of :class:`.FunctionalGroup` - The correct functional groups. + functional_groups: + The correct functional groups. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/molecules/building_block/test_get_num_functional_groups.py b/tests/molecular/molecules/building_block/test_get_num_functional_groups.py index 22d5db98b..9981ab7cf 100644 --- a/tests/molecular/molecules/building_block/test_get_num_functional_groups.py +++ b/tests/molecular/molecules/building_block/test_get_num_functional_groups.py @@ -1,16 +1,18 @@ -def test_get_num_functional_groups(case_data): +from .case_data import CaseData + + +def test_get_num_functional_groups(case_data: CaseData) -> None: """ Test :meth:`.BuildingBlock.get_num_functional_groups`. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. Holds the building block to test and the - correct number of functional groups. + Parameters: + case_data: + A test case. Holds the building block to test and the correct + functional groups. + + Returns: + :class:`NoneType` - Returns - ------- - None : :class:`NoneType` """ diff --git a/tests/molecular/molecules/building_block/test_get_placer_ids.py b/tests/molecular/molecules/building_block/test_get_placer_ids.py index 7ac1d2b8a..d703a88b6 100644 --- a/tests/molecular/molecules/building_block/test_get_placer_ids.py +++ b/tests/molecular/molecules/building_block/test_get_placer_ids.py @@ -1,19 +1,20 @@ import itertools as it +from .case_data import CaseData +import stk -def test_get_placer_ids(case_data): + +def test_get_placer_ids(case_data: CaseData) -> None: """ Test :meth:`.BuildingBlock.get_placer_ids`. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. Holds the building block to test and the - correct placer ids. + Parameters: + case_data: + A test case. Holds the building block to test and the + correct placer ids. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -23,21 +24,22 @@ def test_get_placer_ids(case_data): ) -def _test_get_placer_ids(building_block, placer_ids): +def _test_get_placer_ids( + building_block: stk.BuildingBlock, + placer_ids: tuple[int, ...], +) -> None: """ Test :meth:`.BuildingBlock.get_placer_ids`. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block to test. + Parameters: + building_block: + The building block to test. - placer_ids : :class:`tuple` of :class:`int` - The correct placer ids. + placer_ids: + The correct placer ids. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/molecules/building_block/test_repr.py b/tests/molecular/molecules/building_block/test_repr.py index ae8735aa5..d65c2f7a2 100644 --- a/tests/molecular/molecules/building_block/test_repr.py +++ b/tests/molecular/molecules/building_block/test_repr.py @@ -1,16 +1,18 @@ -def test_repr(case_data): +from .case_data import CaseData + +import stk + + +def test_repr(case_data: CaseData) -> None: """ Test :meth:`.BuildingBlock.__repr__`. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. Holds the building block to test and the correct - functional groups. + Parameters: + case_data: + A test case. Holds the building block to test. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -20,22 +22,21 @@ def test_repr(case_data): ) -def _test_repr(building_block, known_repr): +def _test_repr(building_block: stk.BuildingBlock, known_repr: str) -> None: """ Test :meth:`.BuildingBlock.get_functional_groups`. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block to test. + Parameters: + building_block: + The building block to test. - functional_groups : :class:`tuple` of :class:`.FunctionalGroup` - The correct functional groups. + known_repr: + The correct representation. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ + print(building_block.__repr__(), known_repr) assert building_block.__repr__() == known_repr diff --git a/tests/molecular/molecules/building_block/test_with_functional_groups.py b/tests/molecular/molecules/building_block/test_with_functional_groups.py index f52ff9100..86c712066 100644 --- a/tests/molecular/molecules/building_block/test_with_functional_groups.py +++ b/tests/molecular/molecules/building_block/test_with_functional_groups.py @@ -4,24 +4,27 @@ is_equivalent_building_block, is_equivalent_molecule, ) +import stk +from collections import abc -def test_with_functional_groups(building_block, get_functional_groups): +def test_with_functional_groups( + building_block: stk.BuildingBlock, + get_functional_groups: abc.Callable, +) -> None: """ Test :meth:`.BuildingBlock.with_functional_groups`. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block to test. + Parameters: + building_block: + The building block to test. - get_functional_groups : :class:`callable` - Takes a single parameter, `building_block` and returns the - `functional_groups` parameter to use for this test. + get_functional_groups: + Takes a single parameter, `building_block` and returns the + `functional_groups` parameter to use for this test. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -35,21 +38,22 @@ def test_with_functional_groups(building_block, get_functional_groups): has_same_structure(building_block, clone) -def _test_with_functional_groups(building_block, functional_groups): +def _test_with_functional_groups( + building_block: stk.BuildingBlock, + functional_groups: tuple[stk.FunctionalGroup], +) -> None: """ Test :meth:`.BuildingBlock.with_functional_groups`. - Parameters - ---------- - building_block : :class:`.BuildingBlock` - The building block to test. + Parameters: + building_block: + The building block to test. - functional_groups : :class:`tuple` of :class:`.FunctionalGroup` - The functional groups the new building block should hold. + functional_groups: + The functional groups the new building block should hold. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/mdl_mol/case_data.py b/tests/molecular/writers/mdl_mol/case_data.py index b09cd1049..d272ec412 100644 --- a/tests/molecular/writers/mdl_mol/case_data.py +++ b/tests/molecular/writers/mdl_mol/case_data.py @@ -1,34 +1,40 @@ +import stk + + class CaseData: """ A :class:`.MolWriter` test case. - Attributes - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Attributes: + molecule: + Molecule to test. - writer : :class:`.MolWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. """ - def __init__(self, molecule, writer, string): + def __init__( + self, + molecule: stk.Molecule, + writer: stk.MolWriter, + string: str, + ) -> None: """ Initialize a :class:`.CaseData` instance. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.MolWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. """ diff --git a/tests/molecular/writers/mdl_mol/test_to_string.py b/tests/molecular/writers/mdl_mol/test_to_string.py index 20cd70ffe..ba2214b5b 100644 --- a/tests/molecular/writers/mdl_mol/test_to_string.py +++ b/tests/molecular/writers/mdl_mol/test_to_string.py @@ -1,15 +1,18 @@ -def test_to_string(case_data): +import stk + +from .case_data import CaseData + + +def test_to_string(case_data: CaseData) -> None: """ Test writing of molecule to a string. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -20,24 +23,26 @@ def test_to_string(case_data): ) -def _test_to_string(molecule, writer, string): +def _test_to_string( + molecule: stk.Molecule, + writer: stk.MolWriter, + string: str, +) -> None: """ Test that the written string matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.MolWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/mdl_mol/test_write.py b/tests/molecular/writers/mdl_mol/test_write.py index 751059e64..5de742b59 100644 --- a/tests/molecular/writers/mdl_mol/test_write.py +++ b/tests/molecular/writers/mdl_mol/test_write.py @@ -1,18 +1,22 @@ -def test_write(case_data, tmp_path): +import stk + +from .case_data import CaseData +import pathlib + + +def test_write(case_data: CaseData, tmp_path: pathlib.Path) -> None: """ Test writing of molecule to a file. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - tmp_path : :class:`pathlib2.Path` - Path to temporary directory. + tmp_path: + Path to temporary directory. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -24,27 +28,30 @@ def test_write(case_data, tmp_path): ) -def _test_write(molecule, writer, string, file_path): +def _test_write( + molecule: stk.Molecule, + writer: stk.MolWriter, + string: str, + file_path: pathlib.Path, +) -> None: """ Test that the written file content matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.MolWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - file_path : :class:`str` - Path to temporary file. + file_path: + Path to temporary file. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/pdb/case_data.py b/tests/molecular/writers/pdb/case_data.py index 8392c829c..75295dada 100644 --- a/tests/molecular/writers/pdb/case_data.py +++ b/tests/molecular/writers/pdb/case_data.py @@ -1,41 +1,48 @@ +import stk + + class CaseData: """ A :class:`.PdbWriter` test case. - Attributes - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Attributes: + molecule: + Molecule to test. - writer : :class:`.PdbWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Information about periodic cell. Required for testing writing - of constructed molecules with periodic unit cells. + periodic_info: + Information about periodic cell. Required for testing writing + of constructed molecules with periodic unit cells. """ - def __init__(self, molecule, writer, string, periodic_info): + def __init__( + self, + molecule: stk.Molecule, + writer: stk.PdbWriter, + string: str, + periodic_info: stk.PeriodicInfo | None, + ) -> None: """ Initialize a :class:`.CaseData` instance. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.PdbWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Information about periodic cell. + periodic_info: + Information about periodic cell. """ diff --git a/tests/molecular/writers/pdb/conftest.py b/tests/molecular/writers/pdb/conftest.py index 6aeae6a62..bfea4490d 100644 --- a/tests/molecular/writers/pdb/conftest.py +++ b/tests/molecular/writers/pdb/conftest.py @@ -109,7 +109,7 @@ def _get_cof_case() -> CaseData: " 30 \nCONECT 3 35 " "\nCONECT 14 36 \nEND\n" ), - periodic_info=construction_result.get_periodic_info(), + periodic_info=construction_result.get_periodic_info(), # type: ignore[attr-defined] ) diff --git a/tests/molecular/writers/pdb/test_to_string.py b/tests/molecular/writers/pdb/test_to_string.py index 74a16aff1..41c44a71f 100644 --- a/tests/molecular/writers/pdb/test_to_string.py +++ b/tests/molecular/writers/pdb/test_to_string.py @@ -1,15 +1,18 @@ -def test_to_string(case_data): +import stk + +from .case_data import CaseData + + +def test_to_string(case_data: CaseData) -> None: """ Test writing of molecule to a string. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -21,27 +24,30 @@ def test_to_string(case_data): ) -def _test_to_string(molecule, writer, string, periodic_info=None): +def _test_to_string( + molecule: stk.Molecule, + writer: stk.PdbWriter, + string: str, + periodic_info: stk.PeriodicInfo | None = None, +) -> None: """ Test that the written string matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.PdbWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Periodic information. + periodic_info: + Periodic information. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/pdb/test_write.py b/tests/molecular/writers/pdb/test_write.py index c9fb786a4..548229eaf 100644 --- a/tests/molecular/writers/pdb/test_write.py +++ b/tests/molecular/writers/pdb/test_write.py @@ -1,18 +1,22 @@ -def test_write(case_data, tmp_path): +import stk + +from .case_data import CaseData +import pathlib + + +def test_write(case_data: CaseData, tmp_path: pathlib.Path) -> None: """ Test writing of molecule to a file. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - tmp_path : :class:`pathlib2.Path` - Path to temporary directory. + tmp_path: + Path to temporary directory. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -26,35 +30,33 @@ def test_write(case_data, tmp_path): def _test_write( - molecule, - writer, - string, - file_path, - periodic_info=None, + molecule: stk.Molecule, + writer: stk.PdbWriter, + string: str, + file_path: pathlib.Path, + periodic_info: stk.PeriodicInfo | None = None, ): """ Test that the written file content matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.PdbWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Periodic information. + file_path: + Path to temporary file. - file_path : :class:`str` - Path to temporary file. + periodic_info: + Periodic information. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/turbomole/case_data.py b/tests/molecular/writers/turbomole/case_data.py index 475580943..3a3599781 100644 --- a/tests/molecular/writers/turbomole/case_data.py +++ b/tests/molecular/writers/turbomole/case_data.py @@ -1,41 +1,48 @@ +import stk + + class CaseData: """ A :class:`.TurbomoleWriter` test case. - Attributes - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Attributes: + molecule: + Molecule to test. - writer : :class:`.TurbomoleWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Information about periodic cell. Required for testing writing - of constructed molecules with periodic unit cells. + periodic_info: + Information about periodic cell. Required for testing writing + of constructed molecules with periodic unit cells. """ - def __init__(self, molecule, writer, string, periodic_info): + def __init__( + self, + molecule: stk.Molecule, + writer: stk.TurbomoleWriter, + string: str, + periodic_info: stk.PeriodicInfo | None, + ) -> None: """ Initialize a :class:`.CaseData` instance. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.TurbomoleWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Information about periodic cell. + periodic_info: + Information about periodic cell. """ diff --git a/tests/molecular/writers/turbomole/conftest.py b/tests/molecular/writers/turbomole/conftest.py index f041585e8..eb7ec3835 100644 --- a/tests/molecular/writers/turbomole/conftest.py +++ b/tests/molecular/writers/turbomole/conftest.py @@ -43,7 +43,7 @@ def _get_cof_case() -> CaseData: "1.6749 H\n 7.9667 16.1026 53.582 H\n 7.7801 15.8075 5" "1.7756 H\n$end\n" ), - periodic_info=construction_result.get_periodic_info(), + periodic_info=construction_result.get_periodic_info(), # type: ignore[attr-defined] ) diff --git a/tests/molecular/writers/turbomole/test_to_string.py b/tests/molecular/writers/turbomole/test_to_string.py index 498bc3aa8..6be082930 100644 --- a/tests/molecular/writers/turbomole/test_to_string.py +++ b/tests/molecular/writers/turbomole/test_to_string.py @@ -1,15 +1,18 @@ -def test_to_string(case_data): +import stk + +from .case_data import CaseData + + +def test_to_string(case_data: CaseData) -> None: """ Test writing of molecule to a string. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -21,27 +24,30 @@ def test_to_string(case_data): ) -def _test_to_string(molecule, writer, string, periodic_info=None): +def _test_to_string( + molecule: stk.Molecule, + writer: stk.TurbomoleWriter, + string: str, + periodic_info: stk.PeriodicInfo | None = None, +) -> None: """ Test that the written string matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.TurbomoleWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Periodic information. + periodic_info: + Periodic information. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/turbomole/test_write.py b/tests/molecular/writers/turbomole/test_write.py index c64e11d83..a50818ebf 100644 --- a/tests/molecular/writers/turbomole/test_write.py +++ b/tests/molecular/writers/turbomole/test_write.py @@ -1,21 +1,24 @@ -def test_write(case_data, tmp_path): +import stk + +from .case_data import CaseData +import pathlib + + +def test_write(case_data: CaseData, tmp_path: pathlib.Path) -> None: """ Test writing of molecule to a file. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - tmp_path : :class:`pathlib2.Path` - Path to temporary directory. + tmp_path: + Path to temporary directory. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ - _test_write( molecule=case_data.molecule, writer=case_data.writer, @@ -26,35 +29,33 @@ def test_write(case_data, tmp_path): def _test_write( - molecule, - writer, - string, - file_path, - periodic_info=None, + molecule: stk.Molecule, + writer: stk.TurbomoleWriter, + string: str, + file_path: pathlib.Path, + periodic_info: stk.PeriodicInfo | None = None, ): """ Test that the written file content matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.TurbomoleWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - periodic_info : :class:`.PeriodicInfo` - Periodic information. + file_path: + Path to temporary file. - file_path : :class:`str` - Path to temporary file. + periodic_info: + Periodic information. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/xyz/case_data.py b/tests/molecular/writers/xyz/case_data.py index 13a6c1060..e5ece89ed 100644 --- a/tests/molecular/writers/xyz/case_data.py +++ b/tests/molecular/writers/xyz/case_data.py @@ -1,34 +1,40 @@ +import stk + + class CaseData: """ A :class:`.XyzWriter` test case. - Attributes - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Attributes: + molecule: + Molecule to test. - writer : :class:`.XyzWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. """ - def __init__(self, molecule, writer, string): + def __init__( + self, + molecule: stk.Molecule, + writer: stk.XyzWriter, + string: str, + ) -> None: """ Initialize a :class:`.CaseData` instance. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.XyzWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. """ diff --git a/tests/molecular/writers/xyz/test_to_string.py b/tests/molecular/writers/xyz/test_to_string.py index c13ca7952..f6b3c7659 100644 --- a/tests/molecular/writers/xyz/test_to_string.py +++ b/tests/molecular/writers/xyz/test_to_string.py @@ -1,15 +1,18 @@ -def test_to_string(case_data): +import stk + +from .case_data import CaseData + + +def test_to_string(case_data: CaseData) -> None: """ Test writing of molecule to a string. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -20,24 +23,26 @@ def test_to_string(case_data): ) -def _test_to_string(molecule, writer, string): +def _test_to_string( + molecule: stk.Molecule, + writer: stk.XyzWriter, + string: str, +) -> None: """ Test that the written string matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.XyzWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ diff --git a/tests/molecular/writers/xyz/test_write.py b/tests/molecular/writers/xyz/test_write.py index aa8bccb75..ad2d8dc2d 100644 --- a/tests/molecular/writers/xyz/test_write.py +++ b/tests/molecular/writers/xyz/test_write.py @@ -1,18 +1,22 @@ -def test_write(case_data, tmp_path): +import stk + +from .case_data import CaseData +import pathlib + + +def test_write(case_data: CaseData, tmp_path: pathlib.Path) -> None: """ Test writing of molecule to a file. - Parameters - ---------- - case_data : :class:`.CaseData` - A test case. + Parameters: + case_data: + A test case. - tmp_path : :class:`pathlib2.Path` - Path to temporary directory. + tmp_path: + Path to temporary directory. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """ @@ -24,27 +28,30 @@ def test_write(case_data, tmp_path): ) -def _test_write(molecule, writer, string, file_path): +def _test_write( + molecule: stk.Molecule, + writer: stk.XyzWriter, + string: str, + file_path: pathlib.Path, +) -> None: """ Test that the written file content matches expected string. - Parameters - ---------- - molecule : :class:`.Molecule` - Molecule to test. + Parameters: + molecule: + Molecule to test. - writer : :class:`.XyzWriter` - The writer to test. + writer: + The writer to test. - string : :class:`str` - The expected output string. + string: + The expected output string. - file_path : :class:`str` - Path to temporary file. + file_path: + Path to temporary file. - Returns - ------- - None : :class:`NoneType` + Returns: + :class:`NoneType` """