Exemplo n.º 1
0
 def test_fail_non_euler_b(self):
     p = planning.Euler()
     g = build_graph('ab ba de ed')
     p.forced_plan = lambda *al: None
     try:
         p(g, EhmNo(), 'a', '<context>')
     except AssertionError, e:
         self.assertEqual(e.args, ("Graph is not connected", ))
Exemplo n.º 2
0
    def test_early_stop(self):
        class Some(EhmNo):
            stops = [0, 0, 0, 1]
            __nonzero__ = lambda s: s.stops.pop(0)

        g = build_graph('ab bc cd de ef fg gh ha')
        p = planning.Euler()
        p.forced_plan = lambda *al: None
        plan = p(g, Some(), 'a', '<context>')
        self.assertEqual([x[0] for x in plan], ['ab', 'b', 'bc'])
Exemplo n.º 3
0
 def test_fail_non_euler_a(self):
     p = planning.Euler()
     g = build_graph('ab bc bd')
     p.forced_plan = lambda *al: None
     try:
         p(g, EhmNo(), 'a', '<context>')
     except AssertionError as e:
         self.assertEqual(e.args, ("Graph is not Eulerian", ))
     else:
         self.assert_(False, "Expected exception")
Exemplo n.º 4
0
 def test_completes(self):
     g = build_graph('ab bc cb ba')
     p = planning.Euler()
     p.forced_plan = lambda *al: None
     with timeout(1):
         p(g, EhmNo(), 'a', '<context>')
Exemplo n.º 5
0
 def test_ctor_smoke(self):
     self.assert_(planning.Euler())