예제 #1
0
    def test_badnumber(self):
        try:
            int("a3")
        except:
            exc, stack = sys.get_exc()
            assert "TypeError" in exc

        try:
            float("3ffff")
        except:
            exc, stack = sys.get_exc()
            assert "TypeError" in exc
        assert int("3.0") == 3.0
        assert int("-3.0") == -3.0
예제 #2
0
 def test_index(self):
     a = "012345"
     assert a.index("0") == 0
     try:
         assert a.index("9") == -1
     except:
         assert "ValueError" in sys.get_exc()[0]
예제 #3
0
 def test_str_exc(self):
     try:
         raise "Hello"
     except:
         exc, stack = sys.get_exc()
         assert exc == "Hello"
         assert "test_str_exc" in stack
예제 #4
0
 def runone(self, test, testfunc):
     self.setup(test)
     try:
         testfunc(self)
         return TestResult(test, True, None, None)
     except:
         exc, stack = sys.get_exc()
         return TestResult(test, False, exc, stack)
     self.teardown(test)
예제 #5
0
 def __exit__(self):
     assert self.active
     exc = (None, None, None)
     while self.contexts:
         try:
             if self.contexts.pop(-1).__exit__(*exc):
                 exc = (None, None, None)
         except:
             exc = sys.get_exc()
     self.active = False
     if exc != (None, None, None):
         raise exc[0], exc[1], exc[2]
예제 #6
0
 def __exit__(self):
     assert self.active
     exc = (None,None,None)
     while self.contexts:
         try:
             if self.contexts.pop(-1).__exit__(*exc):
                 exc = (None,None,None)
         except:
             exc = sys.get_exc()
     self.active = False
     if exc != (None,None,None):
         raise exc[0],exc[1],exc[2]
예제 #7
0
 def test_no_exc(self):
     assert sys.get_exc()[0] is None
예제 #8
0
 def test_keyerror(self):
     try:
         {}['a']
     except:
         assert "(tpd_dict_get) KeyError: a" in sys.get_exc()[0]
예제 #9
0
 def test_lessthan(self):
     try:
         assert {'a': 1, 'b': 2} < {'a': 1, 'c': 2}
     except:
         assert 'TypeError' in sys.get_exc()[0]