예제 #1
0
 def test_check_when_correct(self):
     # Write expected behavior like it's always been there
     # Clean up residues
     last_path = 'test_check-last.yml'
     rm(last_path)
     # Run a trace
     with tracing(trace_all=True) as store:
         f1('Traced code')
     # It's correct, so keep quiet
     check('test_check', store)
     # Do NOT dump the store
     self.assertFalse(os.path.exists(last_path))
예제 #2
0
 def test_check_after_code_change(self):
     # Write expected behavior like it's always been there
     with open('test_check.yml', 'w') as fd:
         fd.write(f1_behavior)
     # Clean up residues
     last_path = 'test_check-last.yml'
     rm(last_path)
     # Run a trace
     with tracing(trace_all=True) as store:
         f2('Traced code')
     # Something has changed, tell us about it
     with self.assertRaises(AssertionError) as cm:
         check('test_check', store)
     # Write the new behavior and tell us where
     self.assertIn(last_path, str(cm.exception))
     self.assertTrue(os.path.exists(last_path))