def test_another_function_dryrun_on(self): drypy.set_dryrun(True) result = another_function(1, 2) self.assertEqual(result, 321) # check that sheriff result is equal to deputy result deputy_result = dryrun_another_function(1, 2) self.assertEqual(result, deputy_result)
def test_a_sheriff_deputy_dryrun_on(self): drypy.set_dryrun(True) an_instance = AClass() result = an_instance.a_sheriff('world') self.assertEqual(result, "goodbye world ..") # deputy result must be the sheriff result deputy_result = an_instance.a_sheriff_deputy('zxc') self.assertEqual(deputy_result, result)
def test_a_sheriff_deputy_dryrun_off(self): drypy.set_dryrun(False) an_instance = AClass() result = an_instance.a_sheriff('world') self.assertEqual(result, 'hello world') # check also the deputy in order to verify it is still callable deputy_result = an_instance.a_sheriff_deputy('zxc') self.assertEqual(deputy_result, "goodbye world ..")
def test_dryrun_toggle_from_on(self): drypy.set_dryrun(True) drypy.toggle_dryrun() self.assertEqual(drypy.get_status(), False)
def test_dryrun_set_off(self): drypy.set_dryrun(False) self.assertEqual(drypy.get_status(), False)
def test_dryrun_set_on(self): drypy.set_dryrun(True) self.assertEqual(drypy.get_status(), True)
def test_a_sheriff_which_fallbacks_to_sham_dryrun_on(self): drypy.set_dryrun(True) an_instance = AClass() result = an_instance.a_sheriff_which_fallbacks_to_sham(40, 2) self.assertEqual(result, None)
def test_sheriff_fallback_sham_dryrun_on(self): drypy.set_dryrun(True) self.assertEqual(a_sheriff_which_fallbacks_to_sham(42), None)
def test_another_function_dryrun_off(self): drypy.set_dryrun(False) self.assertEqual(another_function(1, 2), 123) # check that deputy function is still callable self.assertEqual(dryrun_another_function(1, 2), 321)
def test_sheriff_fallback_sham_dryrun_off(self): drypy.set_dryrun(False) self.assertEqual(a_sheriff_which_fallbacks_to_sham(42), 'truth!')
def test_a_method_dryrun_on(self): drypy.set_dryrun(True) an_instance = AClass() self.assertEqual(an_instance.a_method(10, 2), None)
def test_a_method_dryrun_off(self): drypy.set_dryrun(False) an_instance = AClass() self.assertEqual(an_instance.a_method(10, 2), 20)
def test_a_function_dryrun_on(self): drypy.set_dryrun(True) self.assertEqual(a_function(), None)
def test_a_function_dryrun_off(self): drypy.set_dryrun(False) self.assertEqual(a_function(), True)