Ejemplo n.º 1
0
		def wrapped(*args):
			if not manual_session and not use_fixture:
				s, p = new_session(mapgen=mapgen, human_player=human_player, ai_players=ai_players)
			elif use_fixture:
				path = os.path.join(TEST_FIXTURES_DIR, use_fixture + '.sqlite')
				if not os.path.exists(path):
					raise Exception('Savegame {} not found'.format(path))
				s = load_session(path)

			timelimit = Timer(handler)
			timelimit.start(timeout)

			try:
				if use_fixture:
					return func(s, *args)
				elif not manual_session:
					return func(s, p, *args)
				else:
					return func(*args)
			finally:
				try:
					if use_fixture:
						s.end(remove_savegame=False, keep_map=True)
					elif not manual_session:
						s.end()
				except Exception:
					pass
					# An error happened after cleanup after an error.
					# This is ok since cleanup is only defined to work when invariants are in place,
					# but the first error could have violated one.
					# Therefore only use failsafe cleanup:
				finally:
					SPTestSession.cleanup()

				timelimit.stop()
Ejemplo n.º 2
0
def set_trace():
    """
	Use this function instead of directly importing if from pdb. The test run
	time limit will be disabled and stdout restored (so the debugger actually
	works).
	"""
    Timer.stop()

    from nose.tools import set_trace
    set_trace()
Ejemplo n.º 3
0
def set_trace():
	"""
	Use this function instead of directly importing if from pdb. The test run
	time limit will be disabled and stdout restored (so the debugger actually
	works).
	"""
	Timer.stop()

	from nose.tools import set_trace
	set_trace()
Ejemplo n.º 4
0
        def wrapped(*args):
            horizons.globals.db = db
            if not manual_session and not use_fixture:
                s, p = new_session(mapgen=mapgen,
                                   human_player=human_player,
                                   ai_players=ai_players)
            elif use_fixture:
                path = os.path.join(TEST_FIXTURES_DIR, use_fixture + '.sqlite')
                if not os.path.exists(path):
                    raise Exception('Savegame %s not found' % path)
                s = load_session(path)

            timelimit = Timer(handler)
            timelimit.start(timeout)

            try:
                if use_fixture:
                    return func(s, *args)
                elif not manual_session:
                    return func(s, p, *args)
                else:
                    return func(*args)
            finally:
                try:
                    if use_fixture:
                        s.end(remove_savegame=False, keep_map=True)
                    elif not manual_session:
                        s.end()
                except:
                    pass
                    # An error happened after cleanup after an error.
                    # This is ok since cleanup is only defined to work when invariants are in place,
                    # but the first error could have violated one.
                    # Therefore only use failsafe cleanup:
                finally:
                    SPTestSession.cleanup()

                timelimit.stop()