예제 #1
0
from concurrent.futures import Future

import sure  # NOQA

from trypnv.machine import may_handle, message, ModularMachine, Transitions
from trypnv import Machine, StateMachine

from tryp import List, Map

from unit._support.spec import Spec

M1 = message('M1')
M2 = message('M2')
M3 = message('M3')
M4 = message('M4')
M5 = message('M5', 'res')


class _A(Machine):

    @may_handle(M3)
    def m3(self, data, m):
        return (data + ('c', True))

    @may_handle(M1)
    def m1(self, data, m):
        return (data + ('a', True)), M2().pub, M3()


class _B(Machine):
예제 #2
0
import json

from tryp import Just
from tryp.test import Spec

from trypnv.cmd import Command, command, JsonMessageCommand, MessageCommand
from trypnv.machine import message


BasicMessage = message("BasicMessage", "a", "b", opt_fields=(("c", 1), ("d", 2)))


JsonMessage = message("JsonMessage", "a", "b", "json")


class Command_(Spec):
    def name(self):
        def cmd_name(a, b, c=2):
            pass

        Command(cmd_name).name.should.equal("CmdName")
        other_name = "OtherName"
        Command(cmd_name, other_name).name.should.equal(other_name)

    def nargs(self):
        def none():
            pass

        def one(a):
            pass