diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-18 19:27:16 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-18 19:27:16 (GMT) |
commit | a19195984922ce89e7695c93b3bb45c3e0e6d732 (patch) | |
tree | 2cbafae7aa7aa368583be6216a0c23bce0774a0f /Lib/test | |
parent | f61dc4cea24c2e994dc11947a6d67708af87ce50 (diff) | |
parent | 5b89840d9cf11014a4b865d79497649f74bf2866 (diff) | |
download | cpython-a19195984922ce89e7695c93b3bb45c3e0e6d732.zip cpython-a19195984922ce89e7695c93b3bb45c3e0e6d732.tar.gz cpython-a19195984922ce89e7695c93b3bb45c3e0e6d732.tar.bz2 |
Issue #16714: use 'raise' exceptions, don't 'throw'.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_codeop.py | 2 | ||||
-rw-r--r-- | Lib/test/test_docxmlrpc.py | 2 | ||||
-rw-r--r-- | Lib/test/test_imaplib.py | 2 | ||||
-rw-r--r-- | Lib/test/test_minidom.py | 2 | ||||
-rw-r--r-- | Lib/test/test_os.py | 16 | ||||
-rw-r--r-- | Lib/test/test_posix.py | 4 | ||||
-rw-r--r-- | Lib/test/test_pty.py | 2 | ||||
-rw-r--r-- | Lib/test/test_sax.py | 4 | ||||
-rw-r--r-- | Lib/test/test_signal.py | 4 | ||||
-rw-r--r-- | Lib/test/test_socketserver.py | 2 | ||||
-rw-r--r-- | Lib/test/test_sys_settrace.py | 2 | ||||
-rw-r--r-- | Lib/test/test_time.py | 2 | ||||
-rw-r--r-- | Lib/test/test_uu.py | 4 | ||||
-rw-r--r-- | Lib/test/test_winreg.py | 4 | ||||
-rw-r--r-- | Lib/test/test_zipfile.py | 2 |
15 files changed, 27 insertions, 27 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py index d096293..b65423b 100644 --- a/Lib/test/test_codeop.py +++ b/Lib/test/test_codeop.py @@ -50,7 +50,7 @@ class CodeopTests(unittest.TestCase): '''succeed iff str is the start of an invalid piece of code''' try: compile_command(str,symbol=symbol) - self.fail("No exception thrown for invalid code") + self.fail("No exception raised for invalid code") except SyntaxError: self.assertTrue(is_syntax) except OverflowError: diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index 60a69dd..d6ca458 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -100,7 +100,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): self.assertEqual(response.status, 200) self.assertEqual(response.getheader("Content-type"), "text/html") - # Server throws an exception if we don't start to read the data + # Server raises an exception if we don't start to read the data response.read() def test_invalid_get_response(self): diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index 512bba9..06776de 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -115,7 +115,7 @@ class SimpleIMAPHandler(socketserver.StreamRequestHandler): return line += part except IOError: - # ..but SSLSockets throw exceptions. + # ..but SSLSockets raise exceptions. return if line.endswith(b'\r\n'): break diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 0427ba3..5867b2d 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -1073,7 +1073,7 @@ class MinidomTest(unittest.TestCase): '<?xml version="1.0" encoding="utf-16"?>' '<foo>\u20ac</foo>'.encode('utf-16')) - # Verify that character decoding errors throw exceptions instead + # Verify that character decoding errors raise exceptions instead # of crashing self.assertRaises(UnicodeDecodeError, parseString, b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>') diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 13f9e3a..4f86ef5 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -202,33 +202,33 @@ class StatAttributeTests(unittest.TestCase): try: result[200] - self.fail("No exception thrown") + self.fail("No exception raised") except IndexError: pass # Make sure that assignment fails try: result.st_mode = 1 - self.fail("No exception thrown") + self.fail("No exception raised") except AttributeError: pass try: result.st_rdev = 1 - self.fail("No exception thrown") + self.fail("No exception raised") except (AttributeError, TypeError): pass try: result.parrot = 1 - self.fail("No exception thrown") + self.fail("No exception raised") except AttributeError: pass # Use the stat_result constructor with a too-short tuple. try: result2 = os.stat_result((10,)) - self.fail("No exception thrown") + self.fail("No exception raised") except TypeError: pass @@ -273,20 +273,20 @@ class StatAttributeTests(unittest.TestCase): # Make sure that assignment really fails try: result.f_bfree = 1 - self.fail("No exception thrown") + self.fail("No exception raised") except AttributeError: pass try: result.parrot = 1 - self.fail("No exception thrown") + self.fail("No exception raised") except AttributeError: pass # Use the constructor with a too-short tuple. try: result2 = os.statvfs_result((10,)) - self.fail("No exception thrown") + self.fail("No exception raised") except TypeError: pass diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 4ad7350..f4e8aba 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -824,7 +824,7 @@ class PosixTester(unittest.TestCase): posix.rename(support.TESTFN + 'ren', support.TESTFN) raise else: - posix.stat(support.TESTFN) # should not throw exception + posix.stat(support.TESTFN) # should not raise exception finally: posix.close(f) @@ -842,7 +842,7 @@ class PosixTester(unittest.TestCase): def test_unlink_dir_fd(self): f = posix.open(posix.getcwd(), posix.O_RDONLY) support.create_empty_file(support.TESTFN + 'del') - posix.stat(support.TESTFN + 'del') # should not throw exception + posix.stat(support.TESTFN + 'del') # should not raise exception try: posix.unlink(support.TESTFN + 'del', dir_fd=f) except: diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index ef95268..29297f8 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -152,7 +152,7 @@ class PtyTest(unittest.TestCase): # platform-dependent amount of data is written to its fd. On # Linux 2.6, it's 4000 bytes and the child won't block, but on OS # X even the small writes in the child above will block it. Also - # on Linux, the read() will throw an OSError (input/output error) + # on Linux, the read() will raise an OSError (input/output error) # when it tries to read past the end of the buffer but the child's # already exited, so catch and discard those exceptions. It's not # worth checking for EIO. diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 8e00889..7bb30cd 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -389,7 +389,7 @@ class XmlgenTest(unittest.TestCase): def test_5027_1(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had - # a bug whereby a KeyError is thrown because this namespace is missing + # a bug whereby a KeyError is raised because this namespace is missing # from a dictionary. # # This test demonstrates the bug by parsing a document. @@ -415,7 +415,7 @@ class XmlgenTest(unittest.TestCase): def test_5027_2(self): # The xml prefix (as in xml:lang below) is reserved and bound by # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had - # a bug whereby a KeyError is thrown because this namespace is missing + # a bug whereby a KeyError is raised because this namespace is missing # from a dictionary. # # This test demonstrates the bug by direct manipulation of the diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index c04e52b..d2fd84b 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -104,7 +104,7 @@ class InterProcessSignalTests(unittest.TestCase): # This wait should be interrupted by the signal's exception. self.wait(child) time.sleep(1) # Give the signal time to be delivered. - self.fail('HandlerBCalled exception not thrown') + self.fail('HandlerBCalled exception not raised') except HandlerBCalled: self.assertTrue(self.b_called) self.assertFalse(self.a_called) @@ -140,7 +140,7 @@ class InterProcessSignalTests(unittest.TestCase): # test-running process from all the signals. It then # communicates with that child process over a pipe and # re-raises information about any exceptions the child - # throws. The real work happens in self.run_test(). + # raises. The real work happens in self.run_test(). os_done_r, os_done_w = os.pipe() with closing(os.fdopen(os_done_r, 'rb')) as done_r, \ closing(os.fdopen(os_done_w, 'wb')) as done_w: diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 58fc5d03..3dd0d64 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -58,7 +58,7 @@ if HAVE_UNIX_SOCKETS: def simple_subprocess(testcase): pid = os.fork() if pid == 0: - # Don't throw an exception; it would be caught by the test harness. + # Don't raise an exception; it would be caught by the test harness. os._exit(72) yield None pid2, status = os.waitpid(pid, 0) diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index fdf958c..63ae1b7 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -422,7 +422,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase): except ValueError: pass else: - self.fail("exception not thrown!") + self.fail("exception not raised!") except RuntimeError: self.fail("recursion counter not reset") diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 63e1453..da0f555 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -175,7 +175,7 @@ class TimeTestCase(unittest.TestCase): def test_strptime(self): # Should be able to go round-trip from strftime to strptime without - # throwing an exception. + # raising an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index d6875c5..cbf6724 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -80,7 +80,7 @@ class UUTest(unittest.TestCase): out = io.BytesIO() try: uu.decode(inp, out) - self.fail("No exception thrown") + self.fail("No exception raised") except uu.Error as e: self.assertEqual(str(e), "Truncated input file") @@ -89,7 +89,7 @@ class UUTest(unittest.TestCase): out = io.BytesIO() try: uu.decode(inp, out) - self.fail("No exception thrown") + self.fail("No exception raised") except uu.Error as e: self.assertEqual(str(e), "No valid begin line found in input file") diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py index 406c5a2..1100737 100644 --- a/Lib/test/test_winreg.py +++ b/Lib/test/test_winreg.py @@ -245,7 +245,7 @@ class LocalWinregTests(BaseWinregTests): def test_changing_value(self): # Issue2810: A race condition in 2.6 and 3.1 may cause - # EnumValue or QueryValue to throw "WindowsError: More data is + # EnumValue or QueryValue to raise "WindowsError: More data is # available" done = False @@ -291,7 +291,7 @@ class LocalWinregTests(BaseWinregTests): def test_dynamic_key(self): # Issue2810, when the value is dynamically generated, these - # throw "WindowsError: More data is available" in 2.6 and 3.1 + # raise "WindowsError: More data is available" in 2.6 and 3.1 try: EnumValue(HKEY_PERFORMANCE_DATA, 0) except OSError as e: diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 2e52c68..ac6983f 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -1024,7 +1024,7 @@ class OtherTests(unittest.TestCase): with zipfile.ZipFile(data, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!") - # This is correct; calling .read on a closed ZipFile should throw + # This is correct; calling .read on a closed ZipFile should raise # a RuntimeError, and so should calling .testzip. An earlier # version of .testzip would swallow this exception (and any other) # and report that the first file in the archive was corrupt. |