@@ -304,17 +304,16 @@ def test_apply_action_gain_charge(self):
304304 atom = atom0 .copy ()
305305 try :
306306 atom .apply_action (action )
307- self . assertEqual ( len (atom .atomtype ), len (atomtype .increment_charge ) )
307+ assert len (atom .atomtype ) == len (atomtype .increment_charge )
308308 for a in atomtype .increment_charge :
309- self .assertTrue (a in atom .atomtype ,
310- "GAIN_CHARGE on {0} gave {1} not {2}" .format (atomtype , atom .atomtype ,
311- atomtype .increment_charge ))
309+ assert a in atom .atomtype , "GAIN_CHARGE on {0} gave {1} not {2}" .format (atomtype , atom .atomtype ,
310+ atomtype .increment_charge )
312311 # self.assertEqual(atom0.radical_electrons, [r + 1 for r in atom.radical_electrons])
313- self . assertEqual ( atom0 .charge , [c - 1 for c in atom .charge ])
314- self . assertEqual ( atom0 .label , atom .label )
315- self . assertEqual ( atom0 .lone_pairs , atom .lone_pairs )
312+ assert atom0 .charge == [c - 1 for c in atom .charge ]
313+ assert atom0 .label == atom .label
314+ assert atom0 .lone_pairs == atom .lone_pairs
316315 except ActionError :
317- self . assertEqual ( len (atomtype .increment_charge ), 0 )
316+ assert len (atomtype .increment_charge ) == 0
318317
319318 # test when radicals unspecified
320319 group = Group ().from_adjacency_list ("""
@@ -334,17 +333,16 @@ def test_apply_action_lose_charge(self):
334333 atom = atom0 .copy ()
335334 try :
336335 atom .apply_action (action )
337- self . assertEqual ( len (atom .atomtype ), len (atomtype .decrement_charge ) )
336+ assert len (atom .atomtype ) == len (atomtype .decrement_charge )
338337 for a in atomtype .decrement_charge :
339- self .assertTrue (a in atom .atomtype ,
340- "LOSE_CHARGE on {0} gave {1} not {2}" .format (atomtype , atom .atomtype ,
341- atomtype .decrement_charge ))
338+ assert a in atom .atomtype ,"LOSE_CHARGE on {0} gave {1} not {2}" .format (atomtype , atom .atomtype ,
339+ atomtype .decrement_charge )
342340 # self.assertEqual(atom0.radical_electrons, [r - 1 for r in atom.radical_electrons])
343- self . assertEqual ( atom0 .charge , [c + 1 for c in atom .charge ])
344- self . assertEqual ( atom0 .label , atom .label )
345- self . assertEqual ( atom0 .lone_pairs , atom .lone_pairs )
341+ assert atom0 .charge == [c - 1 for c in atom .charge ]
342+ assert atom0 .label == atom .label
343+ assert atom0 .lone_pairs == atom .lone_pairs
346344 except ActionError :
347- self . assertEqual ( len (atomtype .decrement_charge ), 0 )
345+ assert len (atomtype .decrement_charge ) == 0
348346
349347 # test when radicals unspecified
350348 group = Group ().from_adjacency_list ("""
@@ -458,34 +456,6 @@ def test_apply_action_lose_pair(self):
458456 except ActionError :
459457 assert len (atomtype .decrement_lone_pair ) == 0
460458
461- def test_apply_action_gain_charge (self ):
462- """
463- Test the GroupBond.apply_action() method for a GAIN_RADICAL action.
464- """
465- action = ['GAIN_CHARGE' , '*1' , 1 ]
466- for order0 in self .orderList :
467- bond0 = GroupBond (None , None , order = order0 )
468- bond = bond0 .copy ()
469- try :
470- bond .apply_action (action )
471- pytest .fail (reason = 'GroupBond.apply_action() unexpectedly processed a GAIN_CHARGE action.' )
472- except ActionError :
473- pass
474-
475- def test_apply_action_lose_charge (self ):
476- """
477- Test the GroupBond.apply_action() method for a LOSE_CHARGE action.
478- """
479- action = ['LOSE_CHARGE' , '*1' , 1 ]
480- for order0 in self .orderList :
481- bond0 = GroupBond (None , None , order = order0 )
482- bond = bond0 .copy ()
483- try :
484- bond .apply_action (action )
485- pytest .fail (reason = 'GroupBond.apply_action() unexpectedly processed a LOSE_CHARGE action.' )
486- except ActionError :
487- pass
488-
489459 def test_equivalent (self ):
490460 """
491461 Test the GroupAtom.equivalent() method.
@@ -671,14 +641,14 @@ def test_is_electron(self):
671641 Test the GroupAtom.is_electron() method.
672642 """
673643 electron = GroupAtom (atomtype = [ATOMTYPES ['e' ]])
674- self . assertTrue ( electron .is_electron () )
644+ assert electron .is_electron ()
675645
676646 def test_is_proton (self ):
677647 """
678648 Test the GroupAtom.is_proton() method.
679649 """
680650 proton = GroupAtom (atomtype = [ATOMTYPES ['H+' ]])
681- self . assertTrue ( proton .is_proton () )
651+ assert proton .is_proton ()
682652
683653class TestGroupBond :
684654 """
@@ -707,6 +677,35 @@ def test_get_order_str(self):
707677 """
708678 bond = GroupBond (None , None , order = [1 , 2 , 3 , 1.5 ])
709679 assert bond .get_order_str () == ["S" , "D" , "T" , "B" ]
680+
681+
682+ def test_apply_action_gain_charge (self ):
683+ """
684+ Test the GroupBond.apply_action() method for a GAIN_RADICAL action.
685+ """
686+ action = ['GAIN_CHARGE' , '*1' , 1 ]
687+ for order0 in self .orderList :
688+ bond0 = GroupBond (None , None , order = order0 )
689+ bond = bond0 .copy ()
690+ try :
691+ bond .apply_action (action )
692+ pytest .fail (reason = 'GroupBond.apply_action() unexpectedly processed a GAIN_CHARGE action.' )
693+ except ActionError :
694+ pass
695+
696+ def test_apply_action_lose_charge (self ):
697+ """
698+ Test the GroupBond.apply_action() method for a LOSE_CHARGE action.
699+ """
700+ action = ['LOSE_CHARGE' , '*1' , 1 ]
701+ for order0 in self .orderList :
702+ bond0 = GroupBond (None , None , order = order0 )
703+ bond = bond0 .copy ()
704+ try :
705+ bond .apply_action (action )
706+ pytest .fail (reason = 'GroupBond.apply_action() unexpectedly processed a LOSE_CHARGE action.' )
707+ except ActionError :
708+ pass
710709
711710 def test_set_order_str (self ):
712711 """
@@ -1005,17 +1004,17 @@ def test_is_electron(self):
10051004 """
10061005 Test the Group.is_electron() method.
10071006 """
1008- self .assertFalse ( self . group .is_electron () )
1007+ assert not self .group .is_electron ()
10091008 electron = Group ().from_adjacency_list ("""1 *1 e u1 p0 c-1""" )
1010- self . assertTrue ( electron .is_electron () )
1009+ assert electron .is_electron ()
10111010
10121011 def test_is_proton (self ):
10131012 """
10141013 Test the Group.is_proton() method.
10151014 """
1016- self .assertFalse ( self . group .is_proton () )
1015+ assert not self .group .is_proton ()
10171016 proton = Group ().from_adjacency_list ("""1 *1 H+ u0 p0 c+1""" )
1018- self . assertTrue ( proton .is_proton () )
1017+ assert proton .is_proton ()
10191018
10201019 def test_get_labeled_atom (self ):
10211020 """
0 commit comments