Skip to content

Commit 99aead1

Browse files
committed
tests: fix RDKit mocking in _get_linear tests
1 parent b146c1b commit 99aead1

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

tests/unit/CodeEntropy/levels/test_neighbors.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,14 @@ def test_get_linear_true():
188188
class _FakeRDKit_Chem:
189189
"""Class to mock rdkit functionality."""
190190

191+
@staticmethod
191192
def RemoveHs(mol):
192-
rdkit_heavy = MagicMock()
193193
return rdkit_heavy
194194

195195
class HybridizationType:
196-
def SP():
197-
return "SP"
198-
199-
def _get_atoms():
200-
return [a1, a2, a3]
196+
SP = "SP"
201197

202-
rdkit_heavy.GetAtoms = MagicMock(side_effect=_get_atoms)
198+
rdkit_heavy.GetAtoms = MagicMock(return_value=[a1, a2, a3])
203199

204200
a1.GetHybridization = MagicMock(return_value="SP3")
205201
a2.GetHybridization = MagicMock(return_value="SP")
@@ -208,7 +204,7 @@ def _get_atoms():
208204
with patch("CodeEntropy.levels.neighbors.Chem", _FakeRDKit_Chem):
209205
result = neighbors._get_linear(rdkit_mol, number_heavy)
210206

211-
assert result
207+
assert result is True
212208

213209

214210
def test_get_linear_false():
@@ -223,13 +219,12 @@ def test_get_linear_false():
223219
class _FakeRDKit_Chem:
224220
"""Class to mock rdkit functionality."""
225221

222+
@staticmethod
226223
def RemoveHs(mol):
227-
rdkit_heavy = MagicMock()
228224
return rdkit_heavy
229225

230226
class HybridizationType:
231-
def SP():
232-
return "SP"
227+
SP = "SP"
233228

234229
rdkit_heavy.GetAtoms = MagicMock(return_value=[a1, a2, a3])
235230
a1.GetHybridization = MagicMock(return_value="SP3")
@@ -239,4 +234,4 @@ def SP():
239234
with patch("CodeEntropy.levels.neighbors.Chem", _FakeRDKit_Chem):
240235
result = neighbors._get_linear(rdkit_mol, number_heavy)
241236

242-
assert not result
237+
assert result is False

0 commit comments

Comments
 (0)