Exemplo n.º 1
0
    def test_main(self, Configurator):
        from velo import main

        result = main({}, param='value')

        config = Configurator.return_value

        self.assertEqual(config.make_wsgi_app.return_value, result)
Exemplo n.º 2
0
    def test_main(self, Configurator):
        from velo import main

        result = main({}, param='value')

        config = Configurator.return_value

        self.assertEqual(
            config.make_wsgi_app.return_value,
            result
            )
Exemplo n.º 3
0
def main(problem=None, draw=1, single_step=0):
    """
	Create a random racetrack problem, or take one as a parameter. Then,
	repeatedly retrieve next velocity from velo.main and move there, until
	either you crash or you reach the finish line and have velocity (0,0).
	If single_step = 1, then wait for carriage returns between steps.
	"""
    if not problem:
        problem = maketrack.main()
    (p0, f_line, walls) = problem

    if draw:
        turtle.Screen()  # open the graphics window
        turtle.clearscreen()
        tdraw.draw_problem((p0, f_line, walls), title='foo')

    (x, y) = p0
    (u, v) = (0, 0)

    i = 0
    while True:
        i += 1

        if goal_test((x, y), (u, v), f_line):
            print('\nYou win.')
            break

        state = ((x, y), (u, v))
        (u, v) = velo.main(state, f_line, walls)

        (xnew, ynew) = (x + u, y + v)
        print('Move {}: velo.main chose velocity {}'.format(i, (u, v)), end='')
        print(', new position is {}'.format((xnew, ynew)))
        edge = ((x, y), (xnew, ynew))
        if draw:
            draw_edge(edge, 'red')

        if crash(edge, walls):
            print('\nYou have crashed, so you lose.')
            break
        (x, y) = (xnew, ynew)

        if single_step:
            print("\n*** Finished move {}. Hit carriage return to continue.\n".
                  format(i))
            sys.stdin.readline()
Exemplo n.º 4
0
 def app(self):
     if TestController._app is None:
         TestController._app = velo.main(None, **settings)
     return webtest.TestApp(TestController._app)