Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
	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()
Exemplo n.º 4
0
	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'
Exemplo n.º 5
0
	def __init__(self, C):
		Repository.Mixin.__init__(self)
		self.C = C
		self.beforescript = Script('')
		self.afterscript = Script('')
Exemplo n.º 6
0
 def __init__(self, C):
     Repository.Mixin.__init__(self)
     self.C = C
     self.beforescript = Script('')
     self.afterscript = Script('')
Exemplo n.º 7
0
	def setUp(self):
		self.player = Script()
		self.it = Iteration(self.player)
Exemplo n.º 8
0
	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)