Example #1
0
 def test_list_ops(self):
     """Demonstration should support list interface"""
     d = Demonstration()
     e = Example()
     d.append(e)
     self.assertEqual(d, [e])
     f = Example('Test')
     d += [f]
     self.assertEqual(d, [e,f])
Example #2
0
    def test_call(self):
        """Demonstration call should run all of the component tests"""
        orig_out = sys.stdout
        sys.stdout = StringIO()
        d = Demonstration()
        d.append(Example('test comment'))
        d.append(Example(None, 'a = 3'))
        d.append(Example('value of a should be 3', 'print a'))
        d()
        sys.stdout.seek(0)
        self.assertEqual(sys.stdout.read(),
"""
# test comment
>>> a = 3

# value of a should be 3
>>> print a
3
""")
        sys.stdout = orig_out