geom.tests.test

Attributes

test_folder_path

Functions

test_remove_duplicate_xyz_preserves_first_atom_labels()

Tests that duplicate XYZ entries are removed while keeping atom labels aligned.

move_input_geom(folder, geom_file[, optional_file])

Moves the input geometry file into the scratch folder.

move_managed_geom(folder[, remove_optional_file])

Moves managed geometry files to the specified folder and removes temporary files.

move_created_geom(folder)

Moves the generated geometry files to the specified folder and removes temporary files.

compare_mesh_files(→ bool)

Compare two .msh files while allowing small floating-point differences.

test_create_sphere(monkeypatch)

Tests the generation of a spherical geometry and compares it with a reference file.

test_rdkit_optimization(monkeypatch)

Tests the optimization of a molecular structure using RDKit and compares the result with a reference file.

test_create_sphere_core_shell(monkeypatch)

Tests the generation of a sphere core-shell geometry and compares it with a reference file.

test_create_rod(monkeypatch)

Tests the generation of a rod geometry and compares it with a reference file.

test_create_rod_core_shell(monkeypatch)

Tests the generation of a rod core-shell geometry and compares it with a reference file.

test_create_tip(monkeypatch)

Tests the generation of a tip geometry and compares it with a reference file.

test_create_pyramid(monkeypatch)

Tests the generation of a pyramid geometry and compares it with a reference file.

test_create_cone(monkeypatch)

Tests the generation of a cone geometry and compares it with a reference file.

test_create_icosahedra(monkeypatch)

Tests the generation of an icosahedral geometry and compares it with a reference file.

test_create_cuboctahedra(monkeypatch)

Tests the generation of a cuboctahedral geometry and compares it with a reference file.

test_create_decahedra(monkeypatch)

Tests the generation of a decahedral geometry and compares it with a reference file.

test_create_microscope(monkeypatch)

Tests the generation of a microscope geometry and compares it with a reference file.

test_create_graphene_ribbon(monkeypatch)

Tests the generation of a graphene ribbon geometry and compares it with a reference file.

test_create_graphene_disk(monkeypatch)

Tests the generation of a graphene disk geometry and compares it with a reference file.

test_create_graphene_ring(monkeypatch)

Tests the generation of a graphene ring geometry and compares it with a reference file.

test_create_graphene_triangle_armchair(monkeypatch)

Tests the generation of a graphene triangle (armchair type) geometry and compares it with a reference file.

test_create_graphene_triangle_zigzag(monkeypatch)

Tests the generation of a graphene triangle (zigzag type) geometry and compares it with a reference file.

test_specular_geometry(monkeypatch)

Tests the creation of a specular (mirrored) geometry and compares it with a reference file.

test_controlled_distance(monkeypatch)

Tests the controlled translation of a molecule to maintain a specific distance.

test_controlled_rotation(monkeypatch)

Tests the controlled rotation of a molecule along a specified axis.

test_create_dimer(monkeypatch)

Tests the creation of a dimer geometry and validates it against a reference file.

test_create_bowtie(monkeypatch)

Tests the creation of a bowtie geometry and validates it against a reference file.

Module Contents

geom.tests.test_.test_folder_path = b'.'[source]
geom.tests.test_.test_remove_duplicate_xyz_preserves_first_atom_labels()[source]

Tests that duplicate XYZ entries are removed while keeping atom labels aligned.

geom.tests.test_.move_input_geom(folder, geom_file, optional_file=None)[source]

Moves the input geometry file into the scratch folder.

Parameters:
  • folder (str) – The folder where the input file is located.

  • geom_file (str) – The name of the input geometry file to be moved.

  • optional_file (str, optional) – An additional file to move if provided.

Returns:

The function executes shell commands to move files.

Return type:

None

Notes

  • Uses os.system to copy files.

  • If an optional file is provided, it is also copied.

geom.tests.test_.move_managed_geom(folder, remove_optional_file=None)[source]

Moves managed geometry files to the specified folder and removes temporary files.

Parameters:
  • folder (str) – The destination folder for the created geometry files.

  • remove_optional_file (str, optional) – A specific file to be removed if provided.

Returns:

The function executes shell commands to move and remove files.

Return type:

None

Notes

  • Moves generated .xyz files from results_geom to the specified folder.

  • Deletes temporary geometry files and the results_geom directory.

geom.tests.test_.move_created_geom(folder)[source]

Moves the generated geometry files to the specified folder and removes temporary files.

Parameters:

folder (str) – The destination folder for the created geometry files.

Returns:

The function executes shell commands to move and remove files.

Return type:

None

Notes

  • Moves all generated files from results_geom to the specified folder.

  • Deletes the results_geom directory afterward.

geom.tests.test_.compare_mesh_files(file1: str, file2: str, tol: float = 1e-10) bool[source]

Compare two .msh files while allowing small floating-point differences.

This function reads two mesh files and compares them line by line. It ignores non-numeric headers (lines starting with “$”) and allows numerical differences within a specified tolerance (tol). Non-numeric values (e.g., node indices) are compared strictly.

Parameters:
  • file1 (str) – Path to the first .msh file (generated mesh).

  • file2 (str) – Path to the second .msh file (reference mesh).

  • tol (float, optional) – Absolute tolerance for floating-point comparisons. Defaults to 1e-10.

Returns:

True if the files match within the tolerance, False otherwise.

Return type:

bool

Raises:
  • AssertionError – If the files differ in length, structure, or values

  • outside the specified tolerance.

geom.tests.test_.test_create_sphere(monkeypatch)[source]

Tests the generation of a spherical geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of generated output.

Return type:

None

Notes

  • Mocks command-line arguments for sphere creation.

  • Runs the geometry creation process.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_rdkit_optimization(monkeypatch)[source]

Tests the optimization of a molecular structure using RDKit and compares the result with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate that the optimized molecular structure matches the expected reference output.

Return type:

None

Notes

  • Mocks command-line arguments to perform an RDKit-based molecular optimization.

  • Temporarily moves the input .smi file into the test directory.

  • Executes the optimization routine using the specified force field (e.g., MMFF94s).

  • Moves the generated files back to their managed location after execution.

  • Compares the generated .sdf file with an expected reference file.

geom.tests.test_.test_create_sphere_core_shell(monkeypatch)[source]

Tests the generation of a sphere core-shell geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for core-shell sphere creation.

  • Runs the geometry creation process.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_rod(monkeypatch)[source]

Tests the generation of a rod geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for rod creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_rod_core_shell(monkeypatch)[source]

Tests the generation of a rod core-shell geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for core-shell rod creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_tip(monkeypatch)[source]

Tests the generation of a tip geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for tip creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_pyramid(monkeypatch)[source]

Tests the generation of a pyramid geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for pyramid creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_cone(monkeypatch)[source]

Tests the generation of a cone geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for cone creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_icosahedra(monkeypatch)[source]

Tests the generation of an icosahedral geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for icosahedral geometry creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_cuboctahedra(monkeypatch)[source]

Tests the generation of a cuboctahedral geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for cuboctahedral geometry creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_decahedra(monkeypatch)[source]

Tests the generation of a decahedral geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for decahedral geometry creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_microscope(monkeypatch)[source]

Tests the generation of a microscope geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for microscope geometry creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_graphene_ribbon(monkeypatch)[source]

Tests the generation of a graphene ribbon geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for graphene ribbon creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_graphene_disk(monkeypatch)[source]

Tests the generation of a graphene disk geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for graphene disk creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_graphene_ring(monkeypatch)[source]

Tests the generation of a graphene ring geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for graphene ring creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_graphene_triangle_armchair(monkeypatch)[source]

Tests the generation of a graphene triangle (armchair type) geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for graphene armchair triangle creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_graphene_triangle_zigzag(monkeypatch)[source]

Tests the generation of a graphene triangle (zigzag type) geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for graphene zigzag triangle creation.

  • Runs the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_specular_geometry(monkeypatch)[source]

Tests the creation of a specular (mirrored) geometry and compares it with a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for mirroring a geometry.

  • Moves the input file temporarily.

  • Runs the mirroring process.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_controlled_distance(monkeypatch)[source]

Tests the controlled translation of a molecule to maintain a specific distance.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for controlled distance translation.

  • Moves the input file temporarily.

  • Runs the translation process.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_controlled_rotation(monkeypatch)[source]

Tests the controlled rotation of a molecule along a specified axis.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv.

Returns:

Uses assertions to validate the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for controlled rotation.

  • Moves the input file temporarily.

  • Runs the rotation process.

  • Compares the generated .xyz file with an expected reference file.

geom.tests.test_.test_create_dimer(monkeypatch)[source]

Tests the creation of a dimer geometry and validates it against a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv for command-line argument simulation.

Returns:

Uses assertions to verify the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for dimer creation with a conical base structure.

  • Initializes and populates the input class.

  • Executes the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file against an expected reference file.

geom.tests.test_.test_create_bowtie(monkeypatch)[source]

Tests the creation of a bowtie geometry and validates it against a reference file.

Parameters:

monkeypatch (pytest.MonkeyPatch) – A fixture to modify sys.argv for command-line argument simulation.

Returns:

Uses assertions to verify the correctness of the generated .xyz file.

Return type:

None

Notes

  • Mocks command-line arguments for bowtie creation with a conical base structure.

  • Initializes and populates the input class.

  • Executes the geometry creation process.

  • Moves the created geometry files to the test folder.

  • Compares the generated .xyz file against an expected reference file.