diff -r df50f73f03ca Lib/test/_test_multiprocessing.py --- a/Lib/test/_test_multiprocessing.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/_test_multiprocessing.py Thu Nov 14 16:05:03 2013 -0600 @@ -198,7 +198,7 @@ def test_current(self): if self.TYPE == 'threads': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) current = self.current_process() authkey = current.authkey @@ -212,7 +212,7 @@ def test_daemon_argument(self): if self.TYPE == "threads": - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) # By default uses the current process's daemon flag. proc0 = self.Process(target=self._test) @@ -277,7 +277,7 @@ def test_terminate(self): if self.TYPE == 'threads': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) p = self.Process(target=self._test_terminate) p.daemon = True @@ -385,7 +385,7 @@ def test_sentinel(self): if self.TYPE == "threads": - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) event = self.Event() p = self.Process(target=self._test_sentinel, args=(event,)) with self.assertRaises(ValueError): @@ -441,7 +441,7 @@ def test_stderr_flush(self): # sys.stderr is flushed at process shutdown (issue #13812) if self.TYPE == "threads": - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) testfn = test.support.TESTFN self.addCleanup(test.support.unlink, testfn) @@ -469,7 +469,7 @@ def test_sys_exit(self): # See Issue 13854 if self.TYPE == 'threads': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) testfn = test.support.TESTFN self.addCleanup(test.support.unlink, testfn) @@ -678,7 +678,7 @@ try: self.assertEqual(q.qsize(), 0) except NotImplementedError: - return + self.skipTest('qsize method not implemented') q.put(1) self.assertEqual(q.qsize(), 1) q.put(5) @@ -786,7 +786,7 @@ def test_timeout(self): if self.TYPE != 'processes': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) sem = self.Semaphore(0) acquire = TimingWrapper(sem.acquire) @@ -1406,7 +1406,7 @@ def test_thousand(self): if self.TYPE == 'manager': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) passes = 1000 lock = self.Lock() conn, child_conn = self.Pipe(False) @@ -1701,7 +1701,7 @@ def test_map_unplicklable(self): # Issue #19425 -- failure to pickle should not cause a hang if self.TYPE == 'threads': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) class A(object): def __reduce__(self): raise RuntimeError('cannot pickle') @@ -2224,7 +2224,7 @@ def test_sendbytes(self): if self.TYPE != 'processes': - return + self.skipTest('test not appropriate for {}'.format(self.TYPE)) msg = latin('abcdefghijklmnopqrstuvwxyz') a, b = self.Pipe() diff -r df50f73f03ca Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/datetimetester.py Thu Nov 14 16:05:03 2013 -0600 @@ -2028,6 +2028,7 @@ class TestSubclassDateTime(TestDateTime): theclass = SubclassDatetime # Override tests not designed for subclass + @unittest.skip('not appropriate for subclasses') def test_roundtrip(self): pass diff -r df50f73f03ca Lib/test/multibytecodec_support.py --- a/Lib/test/multibytecodec_support.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/multibytecodec_support.py Thu Nov 14 16:05:03 2013 -0600 @@ -73,7 +73,7 @@ def test_xmlcharrefreplace(self): if self.has_iso10646: - return + self.skipTest('encoding contains full ISO 10646 map') s = "\u0b13\u0b23\u0b60 nd eggs" self.assertEqual( @@ -83,7 +83,7 @@ def test_customreplace_encode(self): if self.has_iso10646: - return + self.skipTest('encoding contains full ISO 10646 map') from html.entities import codepoint2name diff -r df50f73f03ca Lib/test/pickletester.py --- a/Lib/test/pickletester.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/pickletester.py Thu Nov 14 16:05:03 2013 -0600 @@ -686,9 +686,11 @@ # make sure that floats are formatted locale independent with proto 0 self.assertEqual(self.dumps(1.2, 0)[0:3], b'F1.') + @unittest.skip('empty abstract test method') def test_reduce(self): pass + @unittest.skip('empty abstract test method') def test_getinitargs(self): pass diff -r df50f73f03ca Lib/test/string_tests.py --- a/Lib/test/string_tests.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/string_tests.py Thu Nov 14 16:05:03 2013 -0600 @@ -663,10 +663,10 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) + @unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4, + 'only applies to 32-bit platforms') def test_replace_overflow(self): # Check for overflow checking on 32 bit machines - if sys.maxsize != 2147483647 or struct.calcsize("P") > 4: - return A2_16 = "A" * (2**16) self.checkraises(OverflowError, A2_16, "replace", "", A2_16) self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) diff -r df50f73f03ca Lib/test/test_array.py --- a/Lib/test/test_array.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_array.py Thu Nov 14 16:05:03 2013 -0600 @@ -946,7 +946,7 @@ try: import gc except ImportError: - return + self.skipTest('gc module not available') a = array.array(self.typecode) l = [iter(a)] l.append(l) diff -r df50f73f03ca Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_asyncio/test_events.py Thu Nov 14 16:05:03 2013 -0600 @@ -792,7 +792,7 @@ def test_internal_fds(self): loop = self.create_event_loop() if not isinstance(loop, selector_events.BaseSelectorEventLoop): - return + self.skipTest('loop is not a BaseSelectorEventLoop') self.assertEqual(1, loop._internal_fds) loop.close() diff -r df50f73f03ca Lib/test/test_codecencodings_iso2022.py --- a/Lib/test/test_codecencodings_iso2022.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_codecencodings_iso2022.py Thu Nov 14 16:05:03 2013 -0600 @@ -36,6 +36,7 @@ # iso2022_kr.txt cannot be used to test "chunk coding": the escape # sequence is only written on the first line + @unittest.skip('iso2022_kr.txt cannot be used to test "chunk coding"') def test_chunkcoding(self): pass diff -r df50f73f03ca Lib/test/test_configparser.py --- a/Lib/test/test_configparser.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_configparser.py Thu Nov 14 16:05:03 2013 -0600 @@ -707,8 +707,7 @@ def test_read_returns_file_list(self): if self.delimiters[0] != '=': - # skip reading the file if we're using an incompatible format - return + self.skipTest('incompatible format') file1 = support.findfile("cfgparser.1") # check when we pass a mix of readable and non-readable files: cf = self.newconfig() diff -r df50f73f03ca Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_decimal.py Thu Nov 14 16:05:03 2013 -0600 @@ -300,7 +300,6 @@ #Exception raised where there shouldn't have been one. self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line) - return def eval_line(self, s): if s.find(' -> ') >= 0 and s[:2] != '--' and not s.startswith(' --'): @@ -460,7 +459,6 @@ self.assertEqual(myexceptions, theirexceptions, 'Incorrect flags set in ' + s + ' -- got ' + str(myexceptions)) - return def getexceptions(self): return [e for e in Signals[self.decimal] if self.context.flags[e]] @@ -1072,7 +1070,7 @@ try: from locale import CHAR_MAX except ImportError: - return + self.skipTest('locale.CHAR_MAX not available') def make_grouping(lst): return ''.join([chr(x) for x in lst]) if self.decimal == C else lst @@ -1163,8 +1161,12 @@ decimal_point = locale.localeconv()['decimal_point'] thousands_sep = locale.localeconv()['thousands_sep'] - if decimal_point != '\u066b' or thousands_sep != '\u066c': - return + if decimal_point != '\u066b': + self.skipTest('inappropriate decimal point separator' + '({!r} not {!r})'.format(decimal_point, '\u066b')) + if thousands_sep != '\u066c': + self.skipTest('inappropriate thousands separator' + '({!r} not {!r})'.format(thousands_sep, '\u066c')) self.assertEqual(format(Decimal('100000000.123'), 'n'), '100\u066c000\u066c000\u066b123') @@ -1514,7 +1516,6 @@ cls.assertTrue(c1.flags[Inexact]) for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: cls.assertFalse(c1.flags[sig]) - return def thfunc2(cls): Decimal = cls.decimal.Decimal @@ -1559,7 +1560,6 @@ cls.assertTrue(thiscontext.flags[Inexact]) for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: cls.assertFalse(thiscontext.flags[sig]) - return class ThreadingTest(unittest.TestCase): '''Unit tests for thread local contexts in Decimal.''' @@ -1601,7 +1601,6 @@ DefaultContext.prec = save_prec DefaultContext.Emax = save_emax DefaultContext.Emin = save_emin - return @unittest.skipUnless(threading, 'threading required') class CThreadingTest(ThreadingTest): @@ -4523,7 +4522,6 @@ self.assertEqual(d1._sign, b1._sign) self.assertEqual(d1._int, b1._int) self.assertEqual(d1._exp, b1._exp) - return Decimal(d1) self.assertEqual(d1._sign, b1._sign) @@ -5269,7 +5267,7 @@ try: from locale import CHAR_MAX except ImportError: - return + self.skipTest('locale.CHAR_MAX not available') def make_grouping(lst): return ''.join([chr(x) for x in lst]) diff -r df50f73f03ca Lib/test/test_dis.py --- a/Lib/test/test_dis.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_dis.py Thu Nov 14 16:05:03 2013 -0600 @@ -210,16 +210,18 @@ def test_bug_708901(self): self.do_disassembly_test(bug708901, dis_bug708901) + # Test has been disabled due to change in the way + # list comps are handled. The byte code now includes + # a memory address and a file location, so they change from + # run to run. + @unittest.skip('disabled due to a change in the way list comps are handled') def test_bug_1333982(self): # XXX: re-enable this test! # This one is checking bytecodes generated for an `assert` statement, # so fails if the tests are run with -O. Skip this test then. - pass # Test has been disabled due to change in the way - # list comps are handled. The byte code now includes - # a memory address and a file location, so they change from - # run to run. - # if __debug__: - # self.do_disassembly_test(bug1333982, dis_bug1333982) + + if __debug__: + self.do_disassembly_test(bug1333982, dis_bug1333982) def test_big_linenos(self): def func(count): diff -r df50f73f03ca Lib/test/test_fileio.py --- a/Lib/test/test_fileio.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_fileio.py Thu Nov 14 16:05:03 2013 -0600 @@ -341,8 +341,7 @@ try: fn = TESTFN.encode("ascii") except UnicodeEncodeError: - # Skip test - return + self.skipTest('could not encode %r to ascii' % TESTFN) f = _FileIO(fn, "w") try: f.write(b"abc") diff -r df50f73f03ca Lib/test/test_float.py --- a/Lib/test/test_float.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_float.py Thu Nov 14 16:05:03 2013 -0600 @@ -71,7 +71,7 @@ # it still has to accept the normal python syntax import locale if not locale.localeconv()['decimal_point'] == ',': - return + self.skipTest('decimal_point is not ","') self.assertEqual(float(" 3.14 "), 3.14) self.assertEqual(float("+3.14 "), 3.14) diff -r df50f73f03ca Lib/test/test_functools.py --- a/Lib/test/test_functools.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_functools.py Thu Nov 14 16:05:03 2013 -0600 @@ -42,20 +42,6 @@ self.assertEqual(p.func, capture) self.assertEqual(p.args, (1, 2)) self.assertEqual(p.keywords, dict(a=10, b=20)) - # attributes should not be writable - if not isinstance(self.partial, type): - return - self.assertRaises(AttributeError, setattr, p, 'func', map) - self.assertRaises(AttributeError, setattr, p, 'args', (1, 2)) - self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2)) - - p = self.partial(hex) - try: - del p.__dict__ - except TypeError: - pass - else: - self.fail('partial object allowed __dict__ to be deleted') def test_argument_checking(self): self.assertRaises(TypeError, self.partial) # need at least a func arg @@ -151,6 +137,21 @@ if c_functools: partial = c_functools.partial + def test_attributes_unwritable(self): + # attributes should not be writable + p = self.partial(capture, 1, 2, a=10, b=20) + self.assertRaises(AttributeError, setattr, p, 'func', map) + self.assertRaises(AttributeError, setattr, p, 'args', (1, 2)) + self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2)) + + p = self.partial(hex) + try: + del p.__dict__ + except TypeError: + pass + else: + self.fail('partial object allowed __dict__ to be deleted') + def test_repr(self): args = (object(), object()) args_repr = ', '.join(repr(a) for a in args) diff -r df50f73f03ca Lib/test/test_grp.py --- a/Lib/test/test_grp.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_grp.py Thu Nov 14 16:05:03 2013 -0600 @@ -26,8 +26,10 @@ for e in entries: self.check_value(e) + def test_values_extended(self): + entries = grp.getgrall() if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest - return + self.skipTest('huge group file, extended test skipped') for e in entries: e2 = grp.getgrgid(e.gr_gid) diff -r df50f73f03ca Lib/test/test_imp.py --- a/Lib/test/test_imp.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_imp.py Thu Nov 14 16:05:03 2013 -0600 @@ -272,7 +272,7 @@ if found[0] is not None: found[0].close() if found[2][2] != imp.C_EXTENSION: - return + self.skipTest("found module doesn't appear to be a C extension") imp.load_module(name, None, *found[1:]) @unittest.skipIf(sys.dont_write_bytecode, diff -r df50f73f03ca Lib/test/test_io.py --- a/Lib/test/test_io.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_io.py Thu Nov 14 16:05:03 2013 -0600 @@ -421,14 +421,9 @@ # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if sys.platform[:3] == 'win' or sys.platform == 'darwin': - if not support.is_resource_enabled("largefile"): - print("\nTesting large file ops skipped on %s." % sys.platform, - file=sys.stderr) - print("It requires %d bytes and a long time." % self.LARGE, - file=sys.stderr) - print("Use 'regrtest.py -u largefile test_io' to run it.", - file=sys.stderr) - return + support.requires( + 'largefile', + 'test requires %s bytes and a long time to run' % self.LARGE) with self.open(support.TESTFN, "w+b", 0) as f: self.large_file_ops(f) with self.open(support.TESTFN, "w+b") as f: @@ -698,6 +693,7 @@ self.assertEqual(42, bufio.fileno()) + @unittest.skip('test having existential crisis') def test_no_fileno(self): # XXX will we always have fileno() function? If so, kill # this test. Else, write it. diff -r df50f73f03ca Lib/test/test_memoryview.py --- a/Lib/test/test_memoryview.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_memoryview.py Thu Nov 14 16:05:03 2013 -0600 @@ -57,7 +57,7 @@ def test_setitem_readonly(self): if not self.ro_type: - return + self.skipTest("no read-only type to test") b = self.ro_type(self._source) oldrefcount = sys.getrefcount(b) m = self._view(b) @@ -71,7 +71,7 @@ def test_setitem_writable(self): if not self.rw_type: - return + self.skipTest("no writable type to test") tp = self.rw_type b = self.rw_type(self._source) oldrefcount = sys.getrefcount(b) @@ -189,13 +189,13 @@ def test_attributes_readonly(self): if not self.ro_type: - return + self.skipTest("no read-only type to test") m = self.check_attributes_with_type(self.ro_type) self.assertEqual(m.readonly, True) def test_attributes_writable(self): if not self.rw_type: - return + self.skipTest("no writable type to test") m = self.check_attributes_with_type(self.rw_type) self.assertEqual(m.readonly, False) @@ -301,7 +301,7 @@ # buffer as writable causing a segfault if using mmap tp = self.ro_type if tp is None: - return + self.skipTest("no read-only type to test") b = tp(self._source) m = self._view(b) i = io.BytesIO(b'ZZZZ') @@ -379,12 +379,12 @@ itemsize = array.array('i').itemsize format = 'i' + @unittest.skip('XXX test should be adapted for non-byte buffers') def test_getbuffer(self): - # XXX Test should be adapted for non-byte buffers pass + @unittest.skip('XXX NotImplementedError: tolist() only supports byte views') def test_tolist(self): - # XXX NotImplementedError: tolist() only supports byte views pass diff -r df50f73f03ca Lib/test/test_minidom.py --- a/Lib/test/test_minidom.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_minidom.py Thu Nov 14 16:05:03 2013 -0600 @@ -360,12 +360,15 @@ and el.getAttribute("spam2") == "bam2") dom.unlink() + @unittest.skip('empty test') def testGetAttrList(self): pass + @unittest.skip('empty test') def testGetAttrValues(self): pass + @unittest.skip('empty test') def testGetAttrLength(self): pass diff -r df50f73f03ca Lib/test/test_nis.py --- a/Lib/test/test_nis.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_nis.py Thu Nov 14 16:05:03 2013 -0600 @@ -12,11 +12,7 @@ maps = nis.maps() except nis.error as msg: # NIS is probably not active, so this test isn't useful - if support.verbose: - print("Test Skipped:", msg) - # Can't raise SkipTest as regrtest only recognizes the exception - # import time. - return + self.skipTest(str(msg)) try: # On some systems, this map is only accessible to the # super user diff -r df50f73f03ca Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_ntpath.py Thu Nov 14 16:05:03 2013 -0600 @@ -218,7 +218,7 @@ import nt tester('ntpath.abspath("C:\\")', "C:\\") except ImportError: - pass + self.skipTest('nt module not available') def test_relpath(self): currentdir = os.path.split(os.getcwd())[-1] diff -r df50f73f03ca Lib/test/test_os.py --- a/Lib/test/test_os.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_os.py Thu Nov 14 16:05:03 2013 -0600 @@ -508,7 +508,7 @@ try: os.stat(r"c:\pagefile.sys") except FileNotFoundError: - pass # file does not exist; cannot run test + self.skipTest(r'c:\pagefile.sys does not exist') except OSError as e: self.fail("Could not stat pagefile.sys") diff -r df50f73f03ca Lib/test/test_posix.py --- a/Lib/test/test_posix.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_posix.py Thu Nov 14 16:05:03 2013 -0600 @@ -684,7 +684,6 @@ self.assertEqual(type(k), item_type) self.assertEqual(type(v), item_type) - @unittest.skipUnless(hasattr(posix, 'getcwd'), 'test needs posix.getcwd()') def test_getcwd_long_pathnames(self): dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef' curdir = os.getcwd() @@ -693,12 +692,9 @@ try: os.mkdir(base_path) os.chdir(base_path) - except: - # Just returning nothing instead of the SkipTest exception, because - # the test results in Error in that case. Is that ok? - # raise unittest.SkipTest("cannot create directory for testing") - return - + except OSError: + self.skipTest("cannot create directory for testing") + else: def _create_and_do_getcwd(dirname, current_path_length = 0): try: os.mkdir(dirname) diff -r df50f73f03ca Lib/test/test_pwd.py --- a/Lib/test/test_pwd.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_pwd.py Thu Nov 14 16:05:03 2013 -0600 @@ -8,8 +8,6 @@ def test_values(self): entries = pwd.getpwall() - entriesbyname = {} - entriesbyuid = {} for e in entries: self.assertEqual(len(e), 7) @@ -32,13 +30,20 @@ # for one uid # self.assertEqual(pwd.getpwuid(e.pw_uid), e) # instead of this collect all entries for one uid - # and check afterwards + # and check afterwards (done in test_values_extended) + + def test_values_extended(self): + entries = pwd.getpwall() + entriesbyname = {} + entriesbyuid = {} + + if len(entries) > 1000: # Huge passwd file (NIS?) -- skip this test + self.skipTest('passwd file is huge; extended test skipped') + + for e in entries: entriesbyname.setdefault(e.pw_name, []).append(e) entriesbyuid.setdefault(e.pw_uid, []).append(e) - if len(entries) > 1000: # Huge passwd file (NIS?) -- skip the rest - return - # check whether the entry returned by getpwuid() # for each uid is among those from getpwall() for this uid for e in entries: diff -r df50f73f03ca Lib/test/test_reprlib.py --- a/Lib/test/test_reprlib.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_reprlib.py Thu Nov 14 16:05:03 2013 -0600 @@ -166,6 +166,7 @@ eq(r([[[[[[{}]]]]]]), "[[[[[[{}]]]]]]") eq(r([[[[[[[{}]]]]]]]), "[[[[[[[...]]]]]]]") + @unittest.skip('hard to catch a cell object') def test_cell(self): # XXX Hmm? How to get at a cell object? pass @@ -273,6 +274,7 @@ eq(repr(foo.foo), "" % foo.__name__) + @unittest.skip('need a suitable object') def test_object(self): # XXX Test the repr of a type with a really long tp_name but with no # tp_repr. WIBNI we had ::Inline? :) @@ -320,6 +322,7 @@ '= 0, "Error resolving host to ip.") try: hname, aliases, ipaddrs = socket.gethostbyaddr(ip) except OSError: # Probably a similar problem as above; skip this test - return + self.skipTest('name lookup failure') all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn(ip) if not fqhn in all_host_names: @@ -977,16 +977,16 @@ try: from socket import inet_pton, AF_INET6, has_ipv6 if not has_ipv6: - return + self.skipTest('IPv6 not available') except ImportError: - return + self.skipTest('could not import needed symbols from socket') if sys.platform == "win32": try: inet_pton(AF_INET6, '::') except OSError as e: if e.winerror == 10022: - return # IPv6 might not be installed on this PC + self.skipTest('IPv6 might not be supported') f = lambda a: inet_pton(AF_INET6, a) assertInvalid = lambda a: self.assertRaises( @@ -1063,16 +1063,16 @@ try: from socket import inet_ntop, AF_INET6, has_ipv6 if not has_ipv6: - return + self.skipTest('IPv6 not available') except ImportError: - return + self.skipTest('could not import needed symbols from socket') if sys.platform == "win32": try: inet_ntop(AF_INET6, b'\x00' * 16) except OSError as e: if e.winerror == 10022: - return # IPv6 might not be installed on this PC + self.skipTest('IPv6 might not be supported') f = lambda a: inet_ntop(AF_INET6, a) assertInvalid = lambda a: self.assertRaises( @@ -1106,7 +1106,7 @@ my_ip_addr = socket.gethostbyname(socket.gethostname()) except OSError: # Probably name lookup wasn't set up right; skip this test - return + self.skipTest('name lookup failure') self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0]) self.assertEqual(name[1], port) diff -r df50f73f03ca Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_strptime.py Thu Nov 14 16:05:03 2013 -0600 @@ -319,7 +319,7 @@ # when time.tzname[0] == time.tzname[1] and time.daylight tz_name = time.tzname[0] if tz_name.upper() in ("UTC", "GMT"): - return + self.skipTest('need non-UTC/GMT timezone') try: original_tzname = time.tzname original_daylight = time.daylight @@ -532,7 +532,7 @@ try: locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8')) except locale.Error: - return + self.skipTest('test needs en_US.UTF8 locale') try: _strptime._strptime_time('10', '%d') # Get id of current cache object. @@ -549,7 +549,7 @@ # If this is the case just suppress the exception and fall-through # to the resetting to the original locale. except locale.Error: - pass + self.skipTest('test needs de_DE.UTF8 locale') # Make sure we don't trample on the locale setting once we leave the # test. finally: diff -r df50f73f03ca Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_tempfile.py Thu Nov 14 16:05:03 2013 -0600 @@ -324,10 +324,9 @@ finally: os.rmdir(dir) + @unittest.skipUnless(has_stat, 'os.stat not available') def test_file_mode(self): # _mkstemp_inner creates files with the proper mode - if not has_stat: - return # ugh, can't use SkipTest. file = self.do_create() mode = stat.S_IMODE(os.stat(file.name).st_mode) @@ -339,10 +338,9 @@ expected = user * (1 + 8 + 64) self.assertEqual(mode, expected) + @unittest.skipUnless(has_spawnl, 'os.spawnl not available') def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes - if not has_spawnl: - return # ugh, can't use SkipTest. if support.verbose: v="v" @@ -378,10 +376,9 @@ "child process caught fatal signal %d" % -retval) self.assertFalse(retval > 0, "child process reports failure %d"%retval) + @unittest.skipUnless(has_textmode, "text mode not available") def test_textmode(self): # _mkstemp_inner can create files in text mode - if not has_textmode: - return # ugh, can't use SkipTest. # A text file is truncated at the first Ctrl+Z byte f = self.do_create(bin=0) @@ -571,10 +568,9 @@ finally: os.rmdir(dir) + @unittest.skipUnless(has_stat, 'os.stat not available') def test_mode(self): # mkdtemp creates directories with the proper mode - if not has_stat: - return # ugh, can't use SkipTest. dir = self.do_create() try: diff -r df50f73f03ca Lib/test/test_thread.py --- a/Lib/test/test_thread.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_thread.py Thu Nov 14 16:05:03 2013 -0600 @@ -68,39 +68,35 @@ thread.stack_size(0) self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default") - if os.name not in ("nt", "posix"): - return - - tss_supported = True + @unittest.skipIf(os.name not in ("nt", "posix"), 'test meant for nt and posix') + def test_nt_and_posix_stack_size(self): try: thread.stack_size(4096) except ValueError: verbose_print("caught expected ValueError setting " "stack_size(4096)") except thread.error: - tss_supported = False - verbose_print("platform does not support changing thread stack " - "size") + self.skipTest("platform does not support changing thread stack " + "size") - if tss_supported: - fail_msg = "stack_size(%d) failed - should succeed" - for tss in (262144, 0x100000, 0): - thread.stack_size(tss) - self.assertEqual(thread.stack_size(), tss, fail_msg % tss) - verbose_print("successfully set stack_size(%d)" % tss) + fail_msg = "stack_size(%d) failed - should succeed" + for tss in (262144, 0x100000, 0): + thread.stack_size(tss) + self.assertEqual(thread.stack_size(), tss, fail_msg % tss) + verbose_print("successfully set stack_size(%d)" % tss) - for tss in (262144, 0x100000): - verbose_print("trying stack_size = (%d)" % tss) - self.next_ident = 0 - self.created = 0 - for i in range(NUMTASKS): - self.newtask() + for tss in (262144, 0x100000): + verbose_print("trying stack_size = (%d)" % tss) + self.next_ident = 0 + self.created = 0 + for i in range(NUMTASKS): + self.newtask() - verbose_print("waiting for all tasks to complete") - self.done_mutex.acquire() - verbose_print("all tasks done") + verbose_print("waiting for all tasks to complete") + self.done_mutex.acquire() + verbose_print("all tasks done") - thread.stack_size(0) + thread.stack_size(0) def test__count(self): # Test the _count() function. diff -r df50f73f03ca Lib/test/test_time.py --- a/Lib/test/test_time.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_time.py Thu Nov 14 16:05:03 2013 -0600 @@ -459,8 +459,7 @@ try: tmp = locale.setlocale(locale.LC_ALL, "fr_FR") except locale.Error: - # skip this test - return + self.skipTest('could not set locale.LC_ALL to fr_FR') # This should not cause an exception time.strftime("%B", (2009,2,1,0,0,0,0,0,0)) diff -r df50f73f03ca Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_unicode.py Thu Nov 14 16:05:03 2013 -0600 @@ -2000,12 +2000,12 @@ self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable self.assertEqual(repr('\U00014000'), "'\\U00014000'") # nonprintable + # This test only affects 32-bit platforms because expandtabs can only take + # an int as the max value, not a 64-bit C long. If expandtabs is changed + # to take a 64-bit long, this test should apply to all platforms. + @unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4, + 'only applies to 32-bit platforms') def test_expandtabs_overflows_gracefully(self): - # This test only affects 32-bit platforms because expandtabs can only take - # an int as the max value, not a 64-bit C long. If expandtabs is changed - # to take a 64-bit long, this test should apply to all platforms. - if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4: - return self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) @support.cpython_only diff -r df50f73f03ca Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_urllibnet.py Thu Nov 14 16:05:03 2013 -0600 @@ -98,11 +98,10 @@ open_url.close() self.assertEqual(code, 404) + # On Windows, socket handles are not file descriptors; this + # test can't pass on Windows. + @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows') def test_fileno(self): - if sys.platform in ('win32',): - # On Windows, socket handles are not file descriptors; this - # test can't pass on Windows. - return # Make sure fd returned by fileno is valid. with self.urlopen("http://www.python.org/", timeout=None) as open_url: fd = open_url.fileno() diff -r df50f73f03ca Lib/test/test_warnings.py --- a/Lib/test/test_warnings.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_warnings.py Thu Nov 14 16:05:03 2013 -0600 @@ -695,7 +695,7 @@ # Explicit tests for the test.support convenience wrapper wmod = self.module if wmod is not sys.modules['warnings']: - return + self.skipTest('module to test is not loaded warnings module') with support.check_warnings(quiet=False) as w: self.assertEqual(w.warnings, []) wmod.simplefilter("always") diff -r df50f73f03ca Lib/test/test_xmlrpc_net.py --- a/Lib/test/test_xmlrpc_net.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_xmlrpc_net.py Thu Nov 14 16:05:03 2013 -0600 @@ -19,7 +19,6 @@ builders = server.getAllBuilders() except OSError as e: self.skipTest("network error: %s" % e) - return self.addCleanup(lambda: server('close')()) # Perform a minimal sanity check on the result, just to be sure diff -r df50f73f03ca Lib/test/test_zipimport.py --- a/Lib/test/test_zipimport.py Thu Nov 14 10:06:18 2013 -0800 +++ b/Lib/test/test_zipimport.py Thu Nov 14 16:05:03 2013 -0600 @@ -136,7 +136,7 @@ # so we'll simply skip it then. Bug #765456. # if "zlib" in sys.builtin_module_names: - return + self.skipTest('zlib is a builtin module') if "zlib" in sys.modules: del sys.modules["zlib"] files = {"zlib.py": (NOW, test_src)}