class Module(object): unittest.addModuleCleanup(module_cleanup_good, 1, 2, 3, four='hello', five='goodbye') unittest.addModuleCleanup(module_cleanup_bad)
def setUpModule(): global signal_blackboard signal_blackboard = { signal.SIGUSR1 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 }, signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } } oldsigs = registerSignals(handle_signals, handle_signals, handle_signals) unittest.addModuleCleanup(registerSignals, *oldsigs)
def setUpModule(): thread_info = threading_helper.threading_setup() unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info) try: old_switchinterval = sys.getswitchinterval() unittest.addModuleCleanup(sys.setswitchinterval, old_switchinterval) sys.setswitchinterval(1e-5) except AttributeError: pass
def test_enterModuleContext(self): cleanups = [] unittest.addModuleCleanup(cleanups.append, 'cleanup1') cm = TestCM(cleanups, 42) self.assertEqual(unittest.enterModuleContext(cm), 42) unittest.addModuleCleanup(cleanups.append, 'cleanup2') unittest.case.doModuleCleanups() self.assertEqual(cleanups, ['enter', 'cleanup2', 'exit', 'cleanup1'])
def setUpModule(): ordering.append('setUpModule') unittest.addModuleCleanup(cleanup1)
def setUpModule(): thread_info = threading_helper.threading_setup() unittest.addModuleCleanup(threading_helper.threading_cleanup, *thread_info)
def setUpModule(): ordering.append('setUpModule2') unittest.addModuleCleanup(cleanup, ordering) if blowUp2: raise Exception()
def setUpModule(): ordering.append('setUpModule') unittest.addModuleCleanup(cleanup, ordering, blowUp=True) if module_blow_up: raise Exception('ModuleExc')
class Module(object): unittest.addModuleCleanup(cleanup, 1, 2, function='hello') with self.assertRaises(TypeError): unittest.addModuleCleanup(function=cleanup, arg='hello') with self.assertRaises(TypeError): unittest.addModuleCleanup()
def setUpModule(): ordering.append('setUpModule') unittest.addModuleCleanup(cleanup, ordering, blowUp=blowUp)
def setUpModule(): print('set up module') unittest.addModuleCleanup(bad_cleanup1) unittest.addModuleCleanup(bad_cleanup2)
def setUpModule(): thread_info = support.threading_setup() unittest.addModuleCleanup(support.threading_cleanup, *thread_info)
json=calldict) result = r.json() print(result) self.assertEqual(result["success"], "yes") # remove participant from event print("remove participant") calldict = { "token": token, "eventid": eventid, "participantid": participantid } r = requests.post('http://localhost:8080/api/remove_participant', json=calldict) result = r.json() print(result) self.assertEqual(result["success"], "yes") # delete event print("remove event") calldict = {"token": token, "eventid": eventid} r = requests.post('http://localhost:8080/api/delete_event', json=calldict) result = r.json() print(result) self.assertEqual(result["success"], "yes") unittest.addModuleCleanup(tearDownModule) if __name__ == '__main__': unittest.main()
def setUpModule(): cm = warnings.catch_warnings() cm.__enter__() unittest.addModuleCleanup(cm.__exit__, None, None, None) warnings.filterwarnings("error", module="<test string>")