class BasicGameTest(unittest.TestCase): def setUp(self): goal = Goal(target='1,2,3,4,5,6,7,8,9,10') rule = Rule(cannot_contains=['range', '1,2,3,4,5,6,7,8,9,10']) self.challenge = Challenge(goal=goal, rules=[rule]) self.code = """l,c=[],1 while c<11:l+=[str(c)];c+=1 print ','.join(l)""" def test_load(self): self.assertEquals( {'rules': [{'must_contains': [], 'cannot_contains': ['range', '1,2,3,4,5,6,7,8,9,10']}], 'goal': {'target': '1,2,3,4,5,6,7,8,9,10'}, 'time': 60}, self.challenge.dict ) def test_tick(self): self.assertEquals(60, self.challenge.dict['time']) self.challenge.tick() self.assertEquals(59, self.challenge.dict['time']) def test_failed_move(self): code = '",".join([x for x in range(1, 10)' score, errors = self.challenge.move(code)
def setUp(self): goal = Goal(target='1,2,3,4,5,6,7,8,9,10') rule = Rule(cannot_contains=['range', '1,2,3,4,5,6,7,8,9,10']) self.challenge = Challenge(goal=goal, rules=[rule]) self.code = """l,c=[],1