class Factory(Repository.Mixin): def __init__(self, C): Repository.Mixin.__init__(self) self.C = C self.beforescript = Script('') self.afterscript = Script('') def create(self): player = self.C() player.beforescript.script = self.beforescript.script player.afterscript.script = self.afterscript.script return player def test_play(self): scope = Scope() self.beforescript.execute(scope) self.afterscript.execute(scope)
def testBasic(self): self.global_factory.beforescript.script = 'i = 2' self.user_factory.beforescript.script = 'j = i' self.iteration_factory.beforescript.script = 'k = j' player = Script('assert i == k') policy = IterationBasedPlayPolicy(player, 2, 3, self.user_factory, self.iteration_factory, self.global_factory) policy.play()
def setUp(self): self.it_factory = IterationFactory() self.player = Script() self.scope = Scope() self.it_factory.beforescript.script = 'i = i + 1' self.user = User(self.player, 2, self.it_factory) self.user.beforescript.script = 'i = 0' self.user.afterscript.script = 'assert i == 2'
def __init__(self, C): Repository.Mixin.__init__(self) self.C = C self.beforescript = Script('') self.afterscript = Script('')
def setUp(self): self.player = Script() self.it = Iteration(self.player)
def testScope(self): player = Script('assert i == k') policy = IterationBasedPlayPolicy(player, 2, 3, self.user_factory, self.iteration_factory, self.global_factory) self.assertRaises(NameError, policy.play_in_single_thread)