Python test.test_support.TestFailed() Examples
The following are 30
code examples of test.test_support.TestFailed().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.test_support
, or try the search function
.
Example #1
Source File: test_codecs.py From BinderFilter with MIT License | 6 votes |
def test_nameprep(self): from encodings.idna import nameprep for pos, (orig, prepped) in enumerate(nameprep_tests): if orig is None: # Skipped continue # The Unicode strings are given in UTF-8 orig = unicode(orig, "utf-8") if prepped is None: # Input contains prohibited characters self.assertRaises(UnicodeError, nameprep, orig) else: prepped = unicode(prepped, "utf-8") try: self.assertEqual(nameprep(orig), prepped) except Exception,e: raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
Example #2
Source File: test_threaded_import.py From BinderFilter with MIT License | 6 votes |
def test_import_hangers(): import sys if verbose: print "testing import hangers ...", import test.threaded_import_hangers try: if test.threaded_import_hangers.errors: raise TestFailed(test.threaded_import_hangers.errors) elif verbose: print "OK." finally: # In case this test is run again, make sure the helper module # gets loaded from scratch again. del sys.modules['test.threaded_import_hangers'] # Tricky: When regrtest imports this module, the thread running regrtest # grabs the import lock and won't let go of it until this module returns. # All other threads attempting an import hang for the duration. Since # this test spawns threads that do little *but* import, we can't do that # successfully until after this module finishes importing and regrtest # regains control. To make this work, a special case was added to # regrtest to invoke a module's "test_main" function (if any) after # importing it.
Example #3
Source File: test_imaplib.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #4
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 6 votes |
def keywords(): if verbose: print "Testing keyword args to basic type constructors ..." vereq(int(x=1), 1) vereq(float(x=2), 2.0) vereq(long(x=3), 3L) vereq(complex(imag=42, real=666), complex(666, 42)) vereq(str(object=500), '500') vereq(unicode(string='abc', errors='strict'), u'abc') vereq(tuple(sequence=range(3)), (0, 1, 2)) vereq(list(sequence=(0, 1, 2)), range(3)) # note: as of Python 2.3, dict() no longer has an "items" keyword arg for constructor in (int, float, long, complex, str, unicode, tuple, list, file): try: constructor(bogus_keyword_arg=1) except TypeError: pass else: raise TestFailed("expected TypeError from bogus keyword " "argument to %r" % constructor)
Example #5
Source File: test_codecs.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_nameprep(self): from encodings.idna import nameprep for pos, (orig, prepped) in enumerate(nameprep_tests): if orig is None: # Skipped continue # The Unicode strings are given in UTF-8 orig = unicode(orig, "utf-8") if prepped is None: # Input contains prohibited characters self.assertRaises(UnicodeError, nameprep, orig) else: prepped = unicode(prepped, "utf-8") try: self.assertEqual(nameprep(orig), prepped) except Exception,e: raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
Example #6
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 6 votes |
def ints(): if verbose: print "Testing int operations..." numops(100, 3) # The following crashes in Python 2.2 vereq((1).__nonzero__(), 1) vereq((0).__nonzero__(), 0) # This returns 'NotImplemented' in Python 2.2 class C(int): def __add__(self, other): return NotImplemented vereq(C(5L), 5) try: C() + "" except TypeError: pass else: raise TestFailed, "NotImplemented should have caused TypeError" import sys try: C(sys.maxint+1) except OverflowError: pass else: raise TestFailed, "should have raised OverflowError"
Example #7
Source File: test_coercion.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_infinite_rec_classic_classes(self): # if __coerce__() returns its arguments reversed it causes an infinite # recursion for classic classes. class Tester: def __coerce__(self, other): return other, self exc = TestFailed("__coerce__() returning its arguments reverse " "should raise RuntimeError") try: Tester() + 1 except (RuntimeError, TypeError): return except: raise exc else: raise exc
Example #8
Source File: test_coercion.py From BinderFilter with MIT License | 6 votes |
def test_infinite_rec_classic_classes(self): # if __coerce__() returns its arguments reversed it causes an infinite # recursion for classic classes. class Tester: def __coerce__(self, other): return other, self exc = TestFailed("__coerce__() returning its arguments reverse " "should raise RuntimeError") try: Tester() + 1 except (RuntimeError, TypeError): return except: raise exc else: raise exc
Example #9
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 6 votes |
def delhook(): if verbose: print "Testing __del__ hook..." log = [] class C(object): def __del__(self): log.append(1) c = C() vereq(log, []) del c extra_collect() vereq(log, [1]) class D(object): pass d = D() try: del d[0] except TypeError: pass else: raise TestFailed, "invalid del() didn't raise TypeError"
Example #10
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 6 votes |
def hashinherit(): if verbose: print "Testing hash of mutable subclasses..." class mydict(dict): pass d = mydict() try: hash(d) except TypeError: pass else: raise TestFailed, "hash() of dict subclass should fail" class mylist(list): pass d = mylist() try: hash(d) except TypeError: pass else: raise TestFailed, "hash() of list subclass should fail"
Example #11
Source File: test_imaplib.py From BinderFilter with MIT License | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #12
Source File: test_threaded_import.py From oss-ftp with MIT License | 6 votes |
def test_import_hangers(): import sys if verbose: print "testing import hangers ...", import test.threaded_import_hangers try: if test.threaded_import_hangers.errors: raise TestFailed(test.threaded_import_hangers.errors) elif verbose: print "OK." finally: # In case this test is run again, make sure the helper module # gets loaded from scratch again. del sys.modules['test.threaded_import_hangers'] # Tricky: When regrtest imports this module, the thread running regrtest # grabs the import lock and won't let go of it until this module returns. # All other threads attempting an import hang for the duration. Since # this test spawns threads that do little *but* import, we can't do that # successfully until after this module finishes importing and regrtest # regains control. To make this work, a special case was added to # regrtest to invoke a module's "test_main" function (if any) after # importing it.
Example #13
Source File: test_coercion.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_infinite_rec_classic_classes(self): # if __coerce__() returns its arguments reversed it causes an infinite # recursion for classic classes. class Tester: def __coerce__(self, other): return other, self exc = TestFailed("__coerce__() returning its arguments reverse " "should raise RuntimeError") try: Tester() + 1 except (RuntimeError, TypeError): return except: raise exc else: raise exc
Example #14
Source File: test_coercion.py From oss-ftp with MIT License | 6 votes |
def test_infinite_rec_classic_classes(self): # if __coerce__() returns its arguments reversed it causes an infinite # recursion for classic classes. class Tester: def __coerce__(self, other): return other, self exc = TestFailed("__coerce__() returning its arguments reverse " "should raise RuntimeError") try: Tester() + 1 except (RuntimeError, TypeError): return except: raise exc else: raise exc
Example #15
Source File: test_imaplib.py From oss-ftp with MIT License | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #16
Source File: test_codecs.py From oss-ftp with MIT License | 6 votes |
def test_nameprep(self): from encodings.idna import nameprep for pos, (orig, prepped) in enumerate(nameprep_tests): if orig is None: # Skipped continue # The Unicode strings are given in UTF-8 orig = unicode(orig, "utf-8") if prepped is None: # Input contains prohibited characters self.assertRaises(UnicodeError, nameprep, orig) else: prepped = unicode(prepped, "utf-8") try: self.assertEqual(nameprep(orig), prepped) except Exception,e: raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
Example #17
Source File: test_bufio.py From medicare-demo with Apache License 2.0 | 6 votes |
def try_one(s): # Since C doesn't guarantee we can write/read arbitrary bytes in text # files, use binary mode. f = open(TESTFN, "wb") # write once with \n and once without f.write(s) f.write("\n") f.write(s) f.close() f = open(TESTFN, "rb") line = f.readline() if line != s + "\n": raise TestFailed("Expected %r got %r" % (s + "\n", line)) line = f.readline() if line != s: raise TestFailed("Expected %r got %r" % (s, line)) line = f.readline() if line: raise TestFailed("Expected EOF but got %r" % line) f.close() # A pattern with prime length, to avoid simple relationships with # stdio buffer sizes.
Example #18
Source File: test_threaded_import.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_import_hangers(): import sys if verbose: print "testing import hangers ...", import test.threaded_import_hangers try: if test.threaded_import_hangers.errors: raise TestFailed(test.threaded_import_hangers.errors) elif verbose: print "OK." finally: # In case this test is run again, make sure the helper module # gets loaded from scratch again. del sys.modules['test.threaded_import_hangers'] # Tricky: When regrtest imports this module, the thread running regrtest # grabs the import lock and won't let go of it until this module returns. # All other threads attempting an import hang for the duration. Since # this test spawns threads that do little *but* import, we can't do that # successfully until after this module finishes importing and regrtest # regains control. To make this work, a special case was added to # regrtest to invoke a module's "test_main" function (if any) after # importing it.
Example #19
Source File: test_threaded_import.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_import_hangers(): import sys if verbose: print "testing import hangers ...", import test.threaded_import_hangers try: if test.threaded_import_hangers.errors: raise TestFailed(test.threaded_import_hangers.errors) elif verbose: print "OK." finally: # In case this test is run again, make sure the helper module # gets loaded from scratch again. del sys.modules['test.threaded_import_hangers'] # Tricky: When regrtest imports this module, the thread running regrtest # grabs the import lock and won't let go of it until this module returns. # All other threads attempting an import hang for the duration. Since # this test spawns threads that do little *but* import, we can't do that # successfully until after this module finishes importing and regrtest # regains control. To make this work, a special case was added to # regrtest to invoke a module's "test_main" function (if any) after # importing it.
Example #20
Source File: test_threaded_import.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_import_hangers(): import sys if verbose: print "testing import hangers ...", import test.threaded_import_hangers try: if test.threaded_import_hangers.errors: raise TestFailed(test.threaded_import_hangers.errors) elif verbose: print "OK." finally: # In case this test is run again, make sure the helper module # gets loaded from scratch again. del sys.modules['test.threaded_import_hangers'] # Tricky: When regrtest imports this module, the thread running regrtest # grabs the import lock and won't let go of it until this module returns. # All other threads attempting an import hang for the duration. Since # this test spawns threads that do little *but* import, we can't do that # successfully until after this module finishes importing and regrtest # regains control. To make this work, a special case was added to # regrtest to invoke a module's "test_main" function (if any) after # importing it.
Example #21
Source File: test_coercion.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_infinite_rec_classic_classes(self): # if __coerce__() returns its arguments reversed it causes an infinite # recursion for classic classes. class Tester: def __coerce__(self, other): return other, self exc = TestFailed("__coerce__() returning its arguments reverse " "should raise RuntimeError") try: Tester() + 1 except (RuntimeError, TypeError): return except: raise exc else: raise exc
Example #22
Source File: test_codecs.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_nameprep(self): from encodings.idna import nameprep for pos, (orig, prepped) in enumerate(nameprep_tests): if orig is None: # Skipped continue # The Unicode strings are given in UTF-8 orig = unicode(orig, "utf-8") if prepped is None: # Input contains prohibited characters self.assertRaises(UnicodeError, nameprep, orig) else: prepped = unicode(prepped, "utf-8") try: self.assertEqual(nameprep(orig), prepped) except Exception,e: raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
Example #23
Source File: test_imaplib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #24
Source File: test_copy.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_copy_reduce_ex(self): class C(object): def __reduce_ex__(self, proto): return "" def __reduce__(self): raise test_support.TestFailed, "shouldn't call this" x = C() y = copy.copy(x) self.assertTrue(y is x)
Example #25
Source File: double_const.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_ok(x, x_str): assert x > 0.0 x2 = eval(x_str) assert x2 > 0.0 diff = abs(x - x2) # If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger # than 0.375 ULP, so adding diff/8 to x2 should have no effect. if x2 + (diff / 8.) != x2: raise TestFailed("Manifest const %s lost too much precision " % x_str)
Example #26
Source File: test_richcmp.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __cmp__(self, other): raise test_support.TestFailed, "Vector.__cmp__() should not be called"
Example #27
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 5 votes |
def recursive__call__(): if verbose: print ("Testing recursive __call__() by setting to instance of " "class ...") class A(object): pass A.__call__ = A() try: A()() except RuntimeError: pass else: raise TestFailed("Recursion limit should have been reached for " "__call__()")
Example #28
Source File: test_copy.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_deepcopy_reduce_ex(self): class C(object): def __reduce_ex__(self, proto): return "" def __reduce__(self): raise test_support.TestFailed, "shouldn't call this" x = C() y = copy.deepcopy(x) self.assertTrue(y is x)
Example #29
Source File: test_threadedtempfile.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_main(): threads = [] thread_info = threading_setup() print "Creating" for i in range(NUM_THREADS): t = TempFileGreedy() threads.append(t) t.start() print "Starting" startEvent.set() print "Reaping" ok = errors = 0 for t in threads: t.join() ok += t.ok_count errors += t.error_count if t.error_count: print '%s errors:\n%s' % (t.getName(), t.errors.getvalue()) msg = "Done: errors %d ok %d" % (errors, ok) print msg if errors: raise TestFailed(msg) threading_cleanup(*thread_info)
Example #30
Source File: test_descr.py From medicare-demo with Apache License 2.0 | 5 votes |
def buffer_inherit(): import binascii # SF bug [#470040] ParseTuple t# vs subclasses. if verbose: print "Testing that buffer interface is inherited ..." class MyStr(str): pass base = 'abc' m = MyStr(base) # b2a_hex uses the buffer interface to get its argument's value, via # PyArg_ParseTuple 't#' code. vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) # It's not clear that unicode will continue to support the character # buffer interface, and this test will fail if that's taken away. class MyUni(unicode): pass base = u'abc' m = MyUni(base) vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) class MyInt(int): pass m = MyInt(42) try: binascii.b2a_hex(m) raise TestFailed('subclass of int should not have a buffer interface') except TypeError: pass