Skip to content

Commit

Permalink
3.6+ compatible tests rewritten for 3.5.0 compatibility
Browse files Browse the repository at this point in the history
Mock methods such as Mock.assert_called_once() are new in 3.6.0.
For compatibility with 3.5+ these have been replaced with
e.g. assertEqual( Mock.call_count, 1 )
  • Loading branch information
bjmorgan committed May 2, 2017
1 parent 1481587 commit 695e679
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_lookup_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_nearest_neighbour_lookup_table_is_initialised( self, mock_generate_near
self.assertEqual( lookup_table.cn_energy, 'baz' )
self.assertEqual( lookup_table.connected_site_pairs, 'qux' )
self.assertEqual( lookup_table.site_specific_coordination_per_site, 'quux' )
mock_generate_nearest_neighbour_lookup_table.assert_called_once()
self.assertEqual( mock_generate_nearest_neighbour_lookup_table.call_count, 1 )

def test_lookup_table_init_with_invalid_hamiltonian_keywork_raises_ValueError( self ):
hamiltonian = 'foo'
Expand Down
8 changes: 4 additions & 4 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def test_reset( self ):
simulation.atoms = Mock( spec=Species )
simulation.atoms.atoms = [ Mock( spec=Atom ), Mock( spec=Atom ) ]
simulation.reset()
simulation.lattice.reset.assert_called()
simulation.atoms.atoms[0].reset.assert_called()
simulation.atoms.atoms[1].reset.assert_called()
self.assertEqual( simulation.lattice.reset.call_count, 1 )
self.assertEqual( simulation.atoms.atoms[0].reset.call_count, 1 )
self.assertEqual( simulation.atoms.atoms[1].reset.call_count, 1 )

def test_set_number_of_atoms( self ):
simulation = Simulation()
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_run_with_equilibration_steps( self ):
simulation.number_of_jumps = 30
simulation.run()
self.assertEqual( simulation.lattice.jump.call_count, 20+30 )
simulation.reset.assert_called()
self.assertEqual( simulation.reset.call_count, 1 )

class SimulationResultsTestCase( unittest.TestCase ):

Expand Down

0 comments on commit 695e679

Please sign in to comment.