示例#1
0
文件: tests.py 项目: 0Chuzz/dzentools
 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')
示例#2
0
文件: tests.py 项目: 0Chuzz/dzentools
 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)")
示例#3
0
文件: tests.py 项目: 0Chuzz/dzentools
 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)
示例#4
0
文件: tests.py 项目: 0Chuzz/dzentools
 def test_iterable(self):
     elm = BarElement()
     def multi_iter(static=["1", "2", "3", None]):
         return static.pop(0)
     elm.update = multi_iter
     self.assertEqual(list(elm), ["1", "2", "3"])
示例#5
0
文件: tests.py 项目: 0Chuzz/dzentools
 def test_fixed_size(self):
     elm = BarElement(size=10)
     elm.update = Mock(return_value="testresult123456")
     self.assertEqual(elm.next(),"testresult")
示例#6
0
文件: tests.py 项目: 0Chuzz/dzentools
 def test_scrolling(self):
     elm = BarElement(size=3, scroll=1)
     elm.update = lambda: "1234"
     self.assertEqual(elm.next(), "123")
     self.assertEqual(elm.next(), "234")