diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/pydoc_mod.py | 27 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 18 | ||||
-rw-r--r-- | Lib/test/test_tarfile.py | 16 |
3 files changed, 31 insertions, 30 deletions
diff --git a/Lib/test/pydoc_mod.py b/Lib/test/pydoc_mod.py index 8601e3f..9c53324 100644 --- a/Lib/test/pydoc_mod.py +++ b/Lib/test/pydoc_mod.py @@ -25,30 +25,3 @@ def doc_func(): def nodoc_func(): pass -"""This is a test module for test_pydoc""" - -__author__ = "Benjamin Peterson" -__credits__ = "Nobody" -__version__ = "1.2.3.4" - - -class A: - """Hello and goodbye""" - def __init__(): - """Wow, I have no function!""" - pass - -class B(object): - NO_MEANING = "eggs" - pass - -def doc_func(): - """ - This function solves all of the world's problems: - hunger - lack of Python - war - """ - -def nodoc_func(): - pass diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index c9a3e1b..71ae0db 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -292,7 +292,7 @@ class ProcessTestCase(unittest.TestCase): self.assertEqual(stdout, None) # When running with a pydebug build, the # of references is outputted # to stderr, so just check if stderr at least started with "pinapple" - self.assert_(stderr.startswith(b"pineapple")) + self.assertEqual(remove_stderr_debug_decorations(stderr), b"pineapple") def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", @@ -307,6 +307,22 @@ class ProcessTestCase(unittest.TestCase): self.assertEqual(remove_stderr_debug_decorations(stderr), b"pineapple") + # This test is Linux specific for simplicity to at least have + # some coverage. It is not a platform specific bug. + if os.path.isdir('/proc/%d/fd' % os.getpid()): + # Test for the fd leak reported in http://bugs.python.org/issue2791. + def test_communicate_pipe_fd_leak(self): + fd_directory = '/proc/%d/fd' % os.getpid() + num_fds_before_popen = len(os.listdir(fd_directory)) + p = subprocess.Popen([sys.executable, '-c', 'print()'], + stdout=subprocess.PIPE) + p.communicate() + num_fds_after_communicate = len(os.listdir(fd_directory)) + del p + num_fds_after_destruction = len(os.listdir(fd_directory)) + self.assertEqual(num_fds_before_popen, num_fds_after_destruction) + self.assertEqual(num_fds_before_popen, num_fds_after_communicate) + def test_communicate_returns(self): # communicate() should return None if no redirection is active p = subprocess.Popen([sys.executable, "-c", diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 9fde707..7e039a6 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -528,7 +528,19 @@ class PaxReadTest(LongnameTest): self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0) -class WriteTest(unittest.TestCase): +class WriteTestBase(unittest.TestCase): + # Put all write tests in here that are supposed to be tested + # in all possible mode combinations. + + def test_fileobj_no_close(self): + fobj = io.BytesIO() + tar = tarfile.open(fileobj=fobj, mode=self.mode) + tar.addfile(tarfile.TarInfo("foo")) + tar.close() + self.assert_(fobj.closed is False, "external fileobjs must never closed") + + +class WriteTest(WriteTestBase): mode = "w:" @@ -651,7 +663,7 @@ class WriteTest(unittest.TestCase): shutil.rmtree(tempdir) -class StreamWriteTest(unittest.TestCase): +class StreamWriteTest(WriteTestBase): mode = "w|" |