diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_cProfile | 12 | ||||
-rw-r--r-- | Lib/test/output/test_profile | 12 | ||||
-rw-r--r-- | Lib/test/test_socket.py | 2 | ||||
-rw-r--r-- | Lib/test/test_zipfile.py | 56 |
4 files changed, 69 insertions, 13 deletions
diff --git a/Lib/test/output/test_cProfile b/Lib/test/output/test_cProfile index 7561bcb6401..1221c63eb87 100644 --- a/Lib/test/output/test_cProfile +++ b/Lib/test/output/test_cProfile @@ -5,7 +5,7 @@ test_cProfile ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.000 1.000 <string>:1(<module>) - 2 0.000 0.000 0.000 0.000 io.py:1212(flush) + 2 0.000 0.000 0.000 0.000 io.py:1213(flush) 1 0.000 0.000 0.000 0.000 io.py:269(flush) 1 0.000 0.000 0.000 0.000 io.py:656(closed) 1 0.000 0.000 0.000 0.000 io.py:874(flush) @@ -30,7 +30,7 @@ test_cProfile Function called... ncalls tottime cumtime <string>:1(<module>) -> 1 0.270 1.000 test_cProfile.py:30(testfunc) -io.py:1212(flush) -> 1 0.000 0.000 io.py:269(flush) +io.py:1213(flush) -> 1 0.000 0.000 io.py:269(flush) 1 0.000 0.000 io.py:874(flush) io.py:269(flush) -> io.py:656(closed) -> @@ -53,7 +53,7 @@ test_cProfile.py:89(helper2_indirect) -> 2 0.006 0.040 test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper) 8 0.000 0.008 {hasattr} {exec} -> 1 0.000 1.000 <string>:1(<module>) - 2 0.000 0.000 io.py:1212(flush) + 2 0.000 0.000 io.py:1213(flush) {hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} -> {method 'disable' of '_lsprof.Profiler' objects} -> @@ -65,10 +65,10 @@ test_cProfile.py:93(helper2) -> 8 0.064 0.080 Function was called by... ncalls tottime cumtime <string>:1(<module>) <- 1 0.000 1.000 {exec} -io.py:1212(flush) <- 2 0.000 0.000 {exec} -io.py:269(flush) <- 1 0.000 0.000 io.py:1212(flush) +io.py:1213(flush) <- 2 0.000 0.000 {exec} +io.py:269(flush) <- 1 0.000 0.000 io.py:1213(flush) io.py:656(closed) <- 1 0.000 0.000 io.py:874(flush) -io.py:874(flush) <- 1 0.000 0.000 io.py:1212(flush) +io.py:874(flush) <- 1 0.000 0.000 io.py:1213(flush) test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper) 12 0.012 0.012 {hasattr} diff --git a/Lib/test/output/test_profile b/Lib/test/output/test_profile index f5e716097b4..0582611a8ff 100644 --- a/Lib/test/output/test_profile +++ b/Lib/test/output/test_profile @@ -10,7 +10,7 @@ test_profile 12 0.000 0.000 0.012 0.001 :0(hasattr) 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 <string>:1(<module>) - 2 0.000 0.000 0.000 0.000 io.py:1212(flush) + 2 0.000 0.000 0.000 0.000 io.py:1213(flush) 1 0.000 0.000 0.000 0.000 io.py:269(flush) 1 0.000 0.000 0.000 0.000 io.py:656(closed) 1 0.000 0.000 0.000 0.000 io.py:874(flush) @@ -33,11 +33,11 @@ Function called... :0(append) -> :0(exc_info) -> :0(exec) -> <string>:1(<module>)(1) 1.000 - io.py:1212(flush)(2) 0.000 + io.py:1213(flush)(2) 0.000 :0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 :0(setprofile) -> <string>:1(<module>) -> test_profile.py:30(testfunc)(1) 1.000 -io.py:1212(flush) -> io.py:269(flush)(1) 0.000 +io.py:1213(flush) -> io.py:269(flush)(1) 0.000 io.py:874(flush)(1) 0.000 io.py:269(flush) -> io.py:656(closed) -> @@ -74,10 +74,10 @@ Function was called by... test_profile.py:93(helper2)(8) 0.400 :0(setprofile) <- profile:0(testfunc())(1) 1.000 <string>:1(<module>) <- :0(exec)(1) 1.000 -io.py:1212(flush) <- :0(exec)(2) 1.000 -io.py:269(flush) <- io.py:1212(flush)(1) 0.000 +io.py:1213(flush) <- :0(exec)(2) 1.000 +io.py:269(flush) <- io.py:1213(flush)(1) 0.000 io.py:656(closed) <- io.py:874(flush)(1) 0.000 -io.py:874(flush) <- io.py:1212(flush)(1) 0.000 +io.py:874(flush) <- io.py:1213(flush)(1) 0.000 profile:0(profiler) <- profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index facf9fda67f..bc31620decb 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1215,7 +1215,7 @@ def test_main(): tests.append(TestLinuxAbstractNamespace) if isTipcAvailable(): tests.append(TIPCTest) - tests.append(TIPCThreadableTest) + tests.append(TIPCThreadableTest) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index ee8150e54e1..7e401da80bf 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -14,6 +14,11 @@ from test.test_support import TESTFN, run_unittest TESTFN2 = TESTFN + "2" FIXEDTEST_SIZE = 1000 +SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'), + ('ziptest2dir/_ziptest2', 'qawsedrftg'), + ('/ziptest2dir/ziptest3dir/_ziptest3', 'azsxdcfvgb'), + ('ziptest2dir/ziptest3dir/ziptest4dir/_ziptest3', '6y7u8i9o0p')] + class TestsWithSourceFile(unittest.TestCase): def setUp(self): self.line_gen = (bytes("Zipfile test line %d. random float: %f" % @@ -289,6 +294,57 @@ class TestsWithSourceFile(unittest.TestCase): self.assertRaises(RuntimeError, zipf.write, TESTFN) zipf.close() + def testExtract(self): + zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) + for fpath, fdata in SMALL_TEST_DATA: + zipfp.writestr(fpath, fdata) + zipfp.close() + + zipfp = zipfile.ZipFile(TESTFN2, "r") + for fpath, fdata in SMALL_TEST_DATA: + writtenfile = zipfp.extract(fpath) + + # make sure it was written to the right place + if os.path.isabs(fpath): + correctfile = os.path.join(os.getcwd(), fpath[1:]) + else: + correctfile = os.path.join(os.getcwd(), fpath) + + self.assertEqual(writtenfile, correctfile) + + # make sure correct data is in correct file + self.assertEqual(fdata.encode(), open(writtenfile, "rb").read()) + + os.remove(writtenfile) + + zipfp.close() + + # remove the test file subdirectories + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + + def testExtractAll(self): + zipfp = zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) + for fpath, fdata in SMALL_TEST_DATA: + zipfp.writestr(fpath, fdata) + zipfp.close() + + zipfp = zipfile.ZipFile(TESTFN2, "r") + zipfp.extractall() + for fpath, fdata in SMALL_TEST_DATA: + if os.path.isabs(fpath): + outfile = os.path.join(os.getcwd(), fpath[1:]) + else: + outfile = os.path.join(os.getcwd(), fpath) + + self.assertEqual(fdata.encode(), open(outfile, "rb").read()) + + os.remove(outfile) + + zipfp.close() + + # remove the test file subdirectories + shutil.rmtree(os.path.join(os.getcwd(), 'ziptest2dir')) + def tearDown(self): os.remove(TESTFN) os.remove(TESTFN2) |