Esempio n. 1
0
 def test_dotty(self):
     idle = State("I")
     fsm = FSM([idle])
     self.assertTrue(idle.dotty() in fsm.dotty())
     self.assertTrue("digraph" in fsm.dotty())
     fname = tempfile.mktemp() + '.dot'
     try:
         f = open(fname, 'w')
         f.write(fsm.dotty())
         f.close()
         try:
             proc = subprocess.Popen(('dot', fname),
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
         except OSError:
             # Graphviz probably not available; skip
             return
         else:
             _, stderr = proc.communicate()
             retcode = proc.poll()
             if retcode:
                 self.fail('Calling dot returned %i (%s)' %
                           (retcode, stderr))
     finally:
         os.unlink(fname)
Esempio n. 2
0
 def test_dotty(self):
     idle = State("I")
     fsm = FSM([idle])
     self.assertTrue(idle.dotty() in fsm.dotty())
     self.assertTrue("digraph" in fsm.dotty())
     fname = tempfile.mktemp() + '.dot'
     try:
         f = open(fname, 'w')
         f.write(fsm.dotty())
         f.close()
         try:
             proc = subprocess.Popen(('dot', fname),
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)
         except OSError:
             # Graphviz probably not available; skip
             return
         else:
             _, stderr = proc.communicate()
             retcode = proc.poll()
             if retcode:
                 self.fail('Calling dot returned %i (%s)' % (retcode,
                                                             stderr))
     finally:
         os.unlink(fname)
Esempio n. 3
0
    def test_reprs(self):
        """
        not really 'testing' here, going for code-coverage to simply
        call the __str__ methods to ensure they don't explode
        """

        a = State("A")
        b = State("B")
        tran = Transition(b, lambda x: None, lambda x: None)
        a.add_transition(tran)
        fsm = FSM([a, b])
        str(fsm)
        str(a)
        str(tran)
        tran.start_state = None
        str(tran)
        fsm.dotty()
Esempio n. 4
0
    def test_reprs(self):
        """
        not really 'testing' here, going for code-coverage to simply
        call the __str__ methods to ensure they don't explode
        """

        a = State("A")
        b = State("B")
        tran = Transition(b, lambda x: None, lambda x: None)
        a.add_transition(tran)
        fsm = FSM([a, b])
        str(fsm)
        str(a)
        str(tran)
        tran.start_state = None
        str(tran)
        fsm.dotty()