def test_electrons_given_invalid(): """ Test that invalid atoms raise error when calling electrons. """ carb = AtomSpec(6, 4) molecule = Molecule([carb], []) with pytest.raises(ValueError): molecule.electrons(1)
def test_electrons(): """Test the number of electrons.""" carb = AtomSpec('C') hyd = AtomSpec('H') atoms = [carb, hyd, hyd, carb, hyd] bonds = [ BondSpec(0, 1, 1), BondSpec(0, 2, 1), BondSpec(0, 3, 2), BondSpec(3, 4, 1), ] molecule = Molecule(atoms, bonds) for node in molecule.nodes: if node == 3: assert molecule.electrons(node) == 1 else: assert molecule.electrons(node) == 0
def test_electrons_expl(): """ Test the number of electrons, 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 molecule.electrons(0) == 0
def test_electrons(): """Test the number of electrons.""" carb = AtomSpec('C') hyd = AtomSpec('H') atoms = [carb, hyd, hyd, hyd, carb, hyd, hyd, hyd] bonds = [ BondSpec(0, 1, 1), BondSpec(0, 2, 1), BondSpec(0, 3, 1), BondSpec(0, 4, 1), BondSpec(4, 5, 1), BondSpec(4, 6, 1), BondSpec(4, 7, 1) ] molecule = Molecule(atoms, bonds) for node in molecule.nodes: assert molecule.electrons(node) == 0
def test_electrons(): """Test the number of electrons.""" molecule = Molecule([AtomSpec('C')], []) assert molecule.electrons(0) == 4