Skip to content

Commit 9958b79

Browse files
committed
remove unittest self.fail syntax, fix more tests, remove more dep meths
1 parent ff8b8d5 commit 9958b79

File tree

16 files changed

+1656
-1661
lines changed

16 files changed

+1656
-1661
lines changed
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
bonds = {
4-
'C-C': 4,
5-
'C-H': 8,
6-
'C=C': 3,
4+
"C-C": 4,
5+
"C-H": 8,
6+
"C=C": 3,
77
}
88

99
externalSymmetry = 1
@@ -12,12 +12,10 @@
1212

1313
opticalIsomers = 1
1414

15-
energy = {
16-
'CBS-QB3': Log('TolueneEnergy.log')
17-
}
15+
energy = {"CBS-QB3": Log("TolueneEnergy.log")}
1816

19-
geometry = Log('TolueneFreq.log')
17+
geometry = Log("TolueneFreq.log")
2018

21-
frequencies = Log('TolueneFreq.log')
19+
frequencies = Log("TolueneFreq.log")
2220

23-
rotors = [HinderedRotorClassicalND(calcPath='TolueneRot1.log', pivots=[[3,12]], tops=[[12,13,14,15]], sigmas=[6], semiclassical=True)]
21+
rotors = [HinderedRotorClassicalND(calcPath="TolueneRot1.log", pivots=[[3, 12]], tops=[[12, 13, 14, 15]], sigmas=[6], semiclassical=True)]

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ markers =
44
functional: functional tests
55
database: database tests
66
# need pytest-cov to do --cov=arkane,rmgpy (?)
7-
addopts = -p julia.pytestplugin --ignore test/regression --last-failed
7+
addopts = -p julia.pytestplugin --ignore test/regression
88
testpaths = test
99
python_files = *Test.py

rmgpy/molecule/inchi.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ cpdef bint _has_unexpected_lone_pairs(Molecule mol)
4545

4646
cpdef list _get_unpaired_electrons(Molecule mol)
4747

48-
cpdef Molecule _generate_minimum_resonance_isomer(Molecule mol)
49-
5048
cpdef list _compute_agglomerate_distance(list agglomerates, Molecule mol)
5149

5250
cpdef bint _is_valid_combo(list combo, Molecule mol, list distances)

scripts/rmg2to3.py

Lines changed: 1510 additions & 1513 deletions
Large diffs are not rendered by default.

test/rmgpy/data/kinetics/kineticsTest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,42 +114,42 @@ def test_load_families_correct(self):
114114
try:
115115
database.load_families(path, families=[])
116116
except DatabaseError:
117-
self.fail("Unable to load families using list []")
117+
assert False, "Unable to load families using list []"
118118

119119
try:
120120
database.load_families(path, families="none")
121121
except DatabaseError:
122-
self.fail("Unable to load families using keyword 'none'")
122+
assert False, "Unable to load families using keyword 'none'"
123123

124124
try:
125125
database.load_families(path, families="default")
126126
except DatabaseError:
127-
self.fail("Unable to load families using keyword 'default'")
127+
assert False, "Unable to load families using keyword 'default'"
128128

129129
try:
130130
database.load_families(path, families=["default", "pah"])
131131
except DatabaseError:
132-
self.fail("Unable to load families using list ['default', 'pah']")
132+
assert False, "Unable to load families using list ['default', 'pah']"
133133

134134
try:
135135
database.load_families(path, families=["R_Addition_MultipleBond"])
136136
except DatabaseError:
137-
self.fail("Unable to load families using list ['R_Addition_MultipleBond']")
137+
assert False, "Unable to load families using list ['R_Addition_MultipleBond']"
138138

139139
try:
140140
database.load_families(path, families=["!H_Abstraction", "!Disproportionation"])
141141
except DatabaseError:
142-
self.fail("Unable to load families using list ['!H_Abstraction', '!Disproportionation']")
142+
assert False, "Unable to load families using list ['!H_Abstraction', '!Disproportionation']"
143143

144144
try:
145145
database.load_families(path, families="!pah")
146146
except DatabaseError:
147-
self.fail("Unable to load families using keyword '!pah'")
147+
assert False, "Unable to load families using keyword '!pah'"
148148

149149
try:
150150
database.load_families(path, families=["H_Abstraction", "pah"])
151151
except DatabaseError:
152-
self.fail("Unable to load families using list ['H_Abstraction', 'pah']")
152+
assert False, "Unable to load families using list ['H_Abstraction', 'pah']"
153153

154154

155155
class TestReactionDegeneracy:

test/rmgpy/molecule/adjlistTest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ def test_check_hund_rule_success(self):
898898
saturate_h=True,
899899
)
900900
except InvalidAdjacencyListError:
901-
self.fail("InvalidAdjacencyListError thrown unexpectedly!")
901+
assert False, "InvalidAdjacencyListError thrown unexpectedly!"
902902

903903
def test_check_multiplicity(self):
904904
"""
@@ -911,7 +911,7 @@ def test_check_multiplicity(self):
911911
1 N u3 p1 c0"""
912912
)
913913
except InvalidAdjacencyListError:
914-
self.fail("InvalidAdjacencyListError thrown unexpectedly for N tri-rad!")
914+
assert False, "InvalidAdjacencyListError thrown unexpectedly for N tri-rad!"
915915

916916
# A general molecule with 4 radicals, multiplicity 5:
917917
try:
@@ -924,7 +924,7 @@ def test_check_multiplicity(self):
924924
5 O u1 p2 c0 {4,S}"""
925925
)
926926
except InvalidAdjacencyListError:
927-
self.fail("InvalidAdjacencyListError thrown unexpectedly for a molecule with 4 radicals, multiplicity 5")
927+
assert False, "InvalidAdjacencyListError thrown unexpectedly for a molecule with 4 radicals, multiplicity 5"
928928

929929
# A general molecule with 4 radicals, multiplicity 3:
930930
try:
@@ -937,7 +937,7 @@ def test_check_multiplicity(self):
937937
5 O u1 p2 c0 {4,S}"""
938938
)
939939
except InvalidAdjacencyListError:
940-
self.fail("InvalidAdjacencyListError thrown unexpectedly for a molecule with 4 radicals, multiplicity 3")
940+
assert False, "InvalidAdjacencyListError thrown unexpectedly for a molecule with 4 radicals, multiplicity 3"
941941

942942
# [N]=C=[N] singlet:
943943
try:
@@ -948,4 +948,4 @@ def test_check_multiplicity(self):
948948
3 N u1 p1 c0 {2,D}"""
949949
)
950950
except InvalidAdjacencyListError:
951-
self.fail("InvalidAdjacencyListError thrown unexpectedly for singlet [N]=C=[N]!")
951+
assert False, "InvalidAdjacencyListError thrown unexpectedly for singlet [N]=C=[N]!"

test/rmgpy/molecule/converterTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_atom_mapping_2(self):
120120
try:
121121
rdkitmol.GetBondBetweenAtoms(rd_atom_indices[at1], rd_atom_indices[at2])
122122
except RuntimeError:
123-
self.fail("RDKit failed in finding the bond in the original atom!")
123+
assert False, "RDKit failed in finding the bond in the original atom!"
124124

125125
def test_atom_mapping_3(self):
126126
"""Test that to_rdkit_mol with save_order=True retains the atom order and create the correct RDKit Molecule"""

test/rmgpy/molecule/graphTest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_add_edge(self):
8383
edge = Edge(vertex1, vertex2)
8484
try:
8585
self.graph.add_edge(edge)
86-
self.fail("Added edge between vertices not in graph to graph.")
86+
assert False, "Added edge between vertices not in graph to graph."
8787
except ValueError:
8888
pass
8989
self.graph.add_vertex(vertex1)
@@ -104,7 +104,7 @@ def test_get_edge(self):
104104
vertex2 = self.graph.vertices[4]
105105
try:
106106
self.graph.get_edge(vertex1, vertex2)
107-
self.fail("Returned an edge between vertices that should not be connected in graph.")
107+
assert False, "Returned an edge between vertices that should not be connected in graph."
108108
except ValueError:
109109
pass
110110
vertex1 = self.graph.vertices[2]

test/rmgpy/molecule/groupTest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def test_apply_action_break_bond(self):
591591
bond = bond0.copy()
592592
try:
593593
bond.apply_action(action)
594-
self.fail("GroupBond.apply_action() unexpectedly processed a BREAK_BOND action.")
594+
assert False, "GroupBond.apply_action() unexpectedly processed a BREAK_BOND action."
595595
except ActionError:
596596
pass
597597

@@ -608,7 +608,7 @@ def test_apply_action_form_bond(self):
608608
bond = bond0.copy()
609609
try:
610610
bond.apply_action(action)
611-
self.fail("GroupBond.apply_action() unexpectedly processed a FORM_BOND action.")
611+
assert False, "GroupBond.apply_action() unexpectedly processed a FORM_BOND action."
612612
except ActionError:
613613
pass
614614

@@ -648,7 +648,7 @@ def test_apply_action_gain_radical(self):
648648
bond = bond0.copy()
649649
try:
650650
bond.apply_action(action)
651-
self.fail("GroupBond.apply_action() unexpectedly processed a GAIN_RADICAL action.")
651+
assert False, "GroupBond.apply_action() unexpectedly processed a GAIN_RADICAL action."
652652
except ActionError:
653653
pass
654654

@@ -662,7 +662,7 @@ def test_apply_action_lose_radical(self):
662662
bond = bond0.copy()
663663
try:
664664
bond.apply_action(action)
665-
self.fail("GroupBond.apply_action() unexpectedly processed a LOSE_RADICAL action.")
665+
assert False, "GroupBond.apply_action() unexpectedly processed a LOSE_RADICAL action."
666666
except ActionError:
667667
pass
668668

@@ -784,7 +784,7 @@ def test_get_labeled_atom(self):
784784
assert atom == self.group.get_labeled_atoms(atom.label)[0]
785785
try:
786786
self.group.get_labeled_atoms("*3")[0]
787-
self.fail("Unexpected successful return from Group.get_labeled_atoms() with invalid atom label.")
787+
assert False, "Unexpected successful return from Group.get_labeled_atoms() with invalid atom label."
788788
except ValueError:
789789
pass
790790

test/rmgpy/molecule/moleculeTest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def test_apply_action_break_bond(self):
689689
bond = bond0.copy()
690690
try:
691691
bond.apply_action(action)
692-
self.fail("Bond.apply_action() unexpectedly processed a BREAK_BOND action " "with order {0}.".format(order0))
692+
assert False, "Bond.apply_action() unexpectedly processed a BREAK_BOND action " "with order {0}.".format(order0)
693693
except ActionError:
694694
pass
695695

@@ -703,7 +703,7 @@ def test_apply_action_form_bond(self):
703703
bond = bond0.copy()
704704
try:
705705
bond.apply_action(action)
706-
self.fail("Bond.apply_action() unexpectedly processed a FORM_BOND action " "with order {0}.".format(order0))
706+
assert False, "Bond.apply_action() unexpectedly processed a FORM_BOND action " "with order {0}.".format(order0)
707707
except ActionError:
708708
pass
709709

@@ -743,7 +743,7 @@ def test_apply_action_gain_radical(self):
743743
bond = bond0.copy()
744744
try:
745745
bond.apply_action(action)
746-
self.fail("Bond.apply_action() unexpectedly processed a GAIN_RADICAL action " "with order {0}.".format(order0))
746+
assert False, "Bond.apply_action() unexpectedly processed a GAIN_RADICAL action " "with order {0}.".format(order0)
747747
except ActionError:
748748
pass
749749

@@ -757,7 +757,7 @@ def test_apply_action_lose_radical(self):
757757
bond = bond0.copy()
758758
try:
759759
bond.apply_action(action)
760-
self.fail("Bond.apply_action() unexpectedly processed a LOSE_RADICAL action " "with order {0}.".format(order0))
760+
assert False, "Bond.apply_action() unexpectedly processed a LOSE_RADICAL action " "with order {0}.".format(order0)
761761
except ActionError:
762762
pass
763763

@@ -999,7 +999,7 @@ def test_get_labeled_atom(self):
999999
assert atom == self.molecule[0].get_labeled_atoms(atom.label)[0]
10001000
try:
10011001
self.molecule[0].get_labeled_atoms("*3")[0]
1002-
self.fail("Unexpected successful return from Molecule.get_labeled_atoms() with invalid atom label.")
1002+
assert False, "Unexpected successful return from Molecule.get_labeled_atoms() with invalid atom label."
10031003
except ValueError:
10041004
pass
10051005

@@ -2190,7 +2190,7 @@ def test_large_mol_update(self):
21902190
try:
21912191
mol.update_connectivity_values()
21922192
except OverflowError:
2193-
self.fail("update_connectivity_values() raised OverflowError unexpectedly!")
2193+
assert False, "update_connectivity_values() raised OverflowError unexpectedly!"
21942194

21952195
def test_large_mol_creation(self):
21962196
"""
@@ -2202,7 +2202,7 @@ def test_large_mol_creation(self):
22022202
try:
22032203
Molecule(smiles=smi)
22042204
except OverflowError:
2205-
self.fail("Creation of C{} failed!".format(i))
2205+
assert False, "Creation of C{} failed!".format(i)
22062206

22072207
def test_get_polycyclic_rings(self):
22082208
"""

0 commit comments

Comments
 (0)