Exemple #1
0
 def test_update(self):
     def updatefunc(static=[0]):
         static[0] += 1
         return "update("+str(static[0])+")"
     elm = BarElement()
     elm.update = Mock(wraps=updatefunc)
     self.assertEqual(elm.next(),"update(1)")
     self.assertEqual(elm.next(),"update(2)")
     self.assertEqual(elm.next(),"update(3)")
Exemple #2
0
 def test_unicode_output(self):
     elm = BarElement()
     elm.update = lambda: u'garçon'
     try:
         self.assertEqual(elm.next(), u'garçon'.encode('utf-8'))
     except UnicodeError:
         self.fail('error in unicode handling')
Exemple #3
0
 def test_graceful_fail(self):
     def wrongfunc():
         raise StandardError
     elm = BarElement()
     elm.update = wrongfunc
     try:
         failed_update = elm.next()
     except StandardError:
         self.fail("uncaught error, no graceful fail")
     else:
         self.assertTrue("Error" in failed_update)
Exemple #4
0
 def test_fixed_size(self):
     elm = BarElement(size=10)
     elm.update = Mock(return_value="testresult123456")
     self.assertEqual(elm.next(),"testresult")
Exemple #5
0
 def test_scrolling(self):
     elm = BarElement(size=3, scroll=1)
     elm.update = lambda: "1234"
     self.assertEqual(elm.next(), "123")
     self.assertEqual(elm.next(), "234")