示例#1
0
    def test_neighbors_given_invalid():
        """
        Test that invalid atoms raise error when calling neighbors.

        """
        carb = AtomSpec(6, 4)
        molecule = Molecule([carb], [])
        with pytest.raises(ValueError):
            molecule.neighbors(1)
示例#2
0
    def test_neighbors_expl():
        """
        Test the number of neighbors, constructed with explicit H.

        """
        carb = AtomSpec('C')
        hyd = AtomSpec('H')

        atoms = [carb, hyd, hyd, hyd, hyd]
        bonds = [
            BondSpec(0, 1, 1),
            BondSpec(0, 2, 1),
            BondSpec(0, 3, 1),
            BondSpec(0, 4, 1),
        ]

        molecule = Molecule(atoms, bonds)
        assert len(molecule.neighbors(0)) == 4
示例#3
0
 def test_neighbors():
     """Test the number of neighbors."""
     molecule = Molecule([AtomSpec('C', 4)], [])
     assert not molecule.neighbors(0)