Exemplo n.º 1
0
 def assertSerializes(self, brain):
     """
     Serializes and unserializes the given brain, asserting that a round
     trip works properly.
     """
     b = Brain(brain)
     self.assertEqual(b, Brain.from_serialized(b.serialize()))
Exemplo n.º 2
0
 def assertSerializes(self, brain):
     """
     Serializes and unserializes the given brain, asserting that a round
     trip works properly.
     """
     b = Brain(brain)
     self.assertEqual(b, Brain.from_serialized(b.serialize()))
Exemplo n.º 3
0
 def assertAsText(self, brain, marker, expected):
     """
     Asserts that Brain(brain).as_text(marker) == expected.
     """
     b = Brain(brain)
     if marker is not None:
         self.assertEqual(b.as_text(marker), expected)
     else:
         self.assertEqual(b.as_text(), expected)
Exemplo n.º 4
0
 def assertAsText(self, brain, marker, expected):
     """
     Asserts that Brain(brain).as_text(marker) == expected.
     """
     b = Brain(brain)
     if marker is not None:
         self.assertEqual(b.as_text(marker), expected)
     else:
         self.assertEqual(b.as_text(), expected)
Exemplo n.º 5
0
 def test_format_input2(self):
     self.assertEqual(
         Brain([Hole(), 'abc', Hole()]),
         Brain.from_serialized(
             'gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAihjZXZlcnlibG9j\nay50ZW1wbGF0ZW1ha2VyLmhvbGUKSG9sZQpxAymBcQR9cQViVQNhYmNxBmgDKYFxB31xCGJlfXEJ\nYi4=\n'
         ))
Exemplo n.º 6
0
 def test_format_input1(self):
     self.assertEqual(
         Brain([]),
         Brain.from_serialized(
             'gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAn1xA2Iu\n'
         ))
Exemplo n.º 7
0
 def assertNumHoles(self, brain, expected):
     """
     Asserts that Brain(brain).num_holes() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.num_holes(), expected)
Exemplo n.º 8
0
 def test_format1(self):
     self.assertEqual(
         Brain([]).serialize(),
         'gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAn1xA2Iu\n'
     )
Exemplo n.º 9
0
 def test_format_input2(self):
     # If this fails due to eg. module renaming, you can recreate
     # correct output like: Brain([Hole(), 'abc', Hole()]).serialize()
     serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECKGNlYmRhdGEudGVtcGxh\ndGVtYWtlci5ob2xlCkhvbGUKcQMpgXEEfXEFYlUDYWJjcQZoAymBcQd9cQhiZX1xCWIu\n'
     self.assertEqual(Brain([Hole(), 'abc', Hole()]),
                      Brain.from_serialized(serialized))
Exemplo n.º 10
0
 def test_format_input1(self):
     # If this fails due to eg. module renaming, you can recreate
     # correct output like: Brain([]).serialize()
     serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECfXEDYi4=\n'
     self.assertEqual(Brain([]), Brain.from_serialized(serialized))
Exemplo n.º 11
0
 def assertConcise(self, brain, expected):
     """
     Asserts that Brain(brain).concise() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.concise(), expected)
Exemplo n.º 12
0
 def assertRegex(self, brain, expected):
     """
     Asserts that Brain(brain).match_regex() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.match_regex(), expected)
Exemplo n.º 13
0
 def assertNumHoles(self, brain, expected):
     """
     Asserts that Brain(brain).num_holes() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.num_holes(), expected)
Exemplo n.º 14
0
 def test_format_input2(self):
     self.assertEqual(Brain([Hole(), 'abc', Hole()]), Brain.from_serialized('gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAihjZXZlcnlibG9j\nay50ZW1wbGF0ZW1ha2VyLmhvbGUKSG9sZQpxAymBcQR9cQViVQNhYmNxBmgDKYFxB31xCGJlfXEJ\nYi4=\n'))
Exemplo n.º 15
0
 def test_format_input1(self):
     self.assertEqual(Brain([]), Brain.from_serialized('gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAn1xA2Iu\n'))
Exemplo n.º 16
0
 def test_format1(self):
     self.assertEqual(
         Brain([]).serialize(),
         'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECfXEDYi4=\n'
     )
Exemplo n.º 17
0
 def test_format_input2(self):
     # If this fails due to eg. module renaming, you can recreate
     # correct output like: Brain([Hole(), 'abc', Hole()]).serialize()
     serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECKGNlYmRhdGEudGVtcGxh\ndGVtYWtlci5ob2xlCkhvbGUKcQMpgXEEfXEFYlUDYWJjcQZoAymBcQd9cQhiZX1xCWIu\n'
     self.assertEqual(Brain([Hole(), 'abc', Hole()]),
                      Brain.from_serialized(serialized))
Exemplo n.º 18
0
 def assertRegex(self, brain, expected):
     """
     Asserts that Brain(brain).match_regex() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.match_regex(), expected)
Exemplo n.º 19
0
 def setUp(self):
     self.template = Template(Brain(['Hello, ', Hole(), '. How are you?']))
Exemplo n.º 20
0
 def setUp(self):
     self.template = Template(Brain([Hole(), ' and bar']))
Exemplo n.º 21
0
 def setUp(self):
     self.template = Template(Brain(['hello']))
Exemplo n.º 22
0
 def test_format2(self):
     self.assertEqual(
         Brain([Hole(), 'abc', Hole()]).serialize(),
         'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECKGNlYmRhdGEudGVtcGxh\ndGVtYWtlci5ob2xlCkhvbGUKcQMpgXEEfXEFYlUDYWJjcQZoAymBcQd9cQhiZX1xCWIu\n'
     )
Exemplo n.º 23
0
 def setUp(self):
     self.template = Template(
         Brain(['<p>', Hole(), ' and ',
                Hole(), '</p>']))
Exemplo n.º 24
0
 def assertConcise(self, brain, expected):
     """
     Asserts that Brain(brain).concise() == expected.
     """
     b = Brain(brain)
     self.assertEqual(b.concise(), expected)
Exemplo n.º 25
0
 def setUp(self):
     self.template = Template(Brain(['foo and ', Hole()]))
Exemplo n.º 26
0
 def test_format_input1(self):
     # If this fails due to eg. module renaming, you can recreate
     # correct output like: Brain([]).serialize()
     serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECfXEDYi4=\n'
     self.assertEqual(Brain([]), Brain.from_serialized(serialized))