[Python-checkins] python/dist/src/Lib/test pickletester.py,1.16,1.17 test_anydbm.py,1.2,1.3 test_binhex.py,1.13,1.14 test_bsddb.py,1.11,1.12 test_commands.py,1.6,1.7 test_dumbdbm.py,1.7,1.8 test_gzip.py,1.10,1.11 test_netrc.py,1.3,1.4 test_pkg.py,1.15,1.16 test_pkgimport.py,1.6,1.7 test_uu.py,1.4,1.5 test_wave.py,1.3,1.4 test_whichdb.py,1.2,1.3

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
2002年8月09日 09:37:38 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv22967/Lib/test
Modified Files:
	pickletester.py test_anydbm.py test_binhex.py test_bsddb.py 
	test_commands.py test_dumbdbm.py test_gzip.py test_netrc.py 
	test_pkg.py test_pkgimport.py test_uu.py test_wave.py 
	test_whichdb.py 
Log Message:
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg). This changes all uses of deprecated tempfile functions to
the recommended ones.
Index: pickletester.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** pickletester.py	30 Jul 2002 23:26:00 -0000	1.16
--- pickletester.py	9 Aug 2002 16:37:35 -0000	1.17
***************
*** 1,4 ****
 import unittest
! from test.test_support import TestFailed, have_unicode
 
 class C:
--- 1,4 ----
 import unittest
! from test.test_support import TestFailed, have_unicode, TESTFN
 
 class C:
***************
*** 270,285 ****
 
 def test_dump_closed_file(self):
! import tempfile, os
! fn = tempfile.mktemp()
! f = open(fn, "w")
! f.close()
! self.assertRaises(ValueError, self.module.dump, 123, f)
! os.remove(fn)
 
 def test_load_closed_file(self):
! import tempfile, os
! fn = tempfile.mktemp()
! f = open(fn, "w")
! f.close()
! self.assertRaises(ValueError, self.module.dump, 123, f)
! os.remove(fn)
--- 270,287 ----
 
 def test_dump_closed_file(self):
! import os
! f = open(TESTFN, "w")
! try:
! f.close()
! self.assertRaises(ValueError, self.module.dump, 123, f)
! finally:
! os.remove(TESTFN)
 
 def test_load_closed_file(self):
! import os
! f = open(TESTFN, "w")
! try:
! f.close()
! self.assertRaises(ValueError, self.module.dump, 123, f)
! finally:
! os.remove(TESTFN)
Index: test_anydbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_anydbm.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_anydbm.py	23 Jul 2002 19:03:43 -0000	1.2
--- test_anydbm.py	9 Aug 2002 16:37:35 -0000	1.3
***************
*** 7,15 ****
 import unittest
 import anydbm
- import tempfile
 import glob
 from test import test_support
 
! _fname = tempfile.mktemp()
 
 def _delete_files():
--- 7,14 ----
 import unittest
 import anydbm
 import glob
 from test import test_support
 
! _fname = test_support.TESTFN
 
 def _delete_files():
Index: test_binhex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_binhex.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_binhex.py	23 Jul 2002 19:03:45 -0000	1.13
--- test_binhex.py	9 Aug 2002 16:37:35 -0000	1.14
***************
*** 7,11 ****
 import binhex
 import os
- import tempfile
 import unittest
 from test import test_support
--- 7,10 ----
***************
*** 15,20 ****
 
 def setUp(self):
! self.fname1 = tempfile.mktemp()
! self.fname2 = tempfile.mktemp()
 
 def tearDown(self):
--- 14,19 ----
 
 def setUp(self):
! self.fname1 = test_support.TESTFN + "1"
! self.fname2 = test_support.TESTFN + "2"
 
 def tearDown(self):
Index: test_bsddb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bsddb.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_bsddb.py	23 Jul 2002 19:23:22 -0000	1.11
--- test_bsddb.py	9 Aug 2002 16:37:35 -0000	1.12
***************
*** 6,11 ****
 import bsddb
 import dbhash # Just so we know it's imported
! import tempfile
! from test.test_support import verbose, verify
 
 def test(openmethod, what, ondisk=1):
--- 6,10 ----
 import bsddb
 import dbhash # Just so we know it's imported
! from test.test_support import verbose, verify, TESTFN
 
 def test(openmethod, what, ondisk=1):
***************
*** 15,19 ****
 
 if ondisk:
! fname = tempfile.mktemp()
 else:
 fname = None
--- 14,18 ----
 
 if ondisk:
! fname = TESTFN
 else:
 fname = None
Index: test_commands.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_commands.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_commands.py	23 Jul 2002 19:03:46 -0000	1.6
--- test_commands.py	9 Aug 2002 16:37:35 -0000	1.7
***************
*** 25,32 ****
 self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy'))
 
! # we use mktemp in the next line to get a filename which we
! # _know_ won't exist. This is guaranteed to fail.
! status, output = getstatusoutput('cat ' + tempfile.mktemp())
! self.assertNotEquals(status, 0)
 
 def test_getstatus(self):
--- 25,39 ----
 self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy'))
 
! # we use mkdtemp in the next line to create an empty directory
! # under our exclusive control; from that, we can invent a pathname
! # that we _know_ won't exist. This is guaranteed to fail.
! try:
! dir = tempfile.mkdtemp()
! name = os.path.join(dir, "foo")
! 
! status, output = getstatusoutput('cat ' + name)
! self.assertNotEquals(status, 0)
! finally:
! os.rmdir(dir)
 
 def test_getstatus(self):
Index: test_dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_dumbdbm.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_dumbdbm.py	23 Jul 2002 19:03:50 -0000	1.7
--- test_dumbdbm.py	9 Aug 2002 16:37:35 -0000	1.8
***************
*** 7,14 ****
 import unittest
 import dumbdbm
- import tempfile
 from test import test_support
 
! _fname = tempfile.mktemp()
 
 def _delete_files():
--- 7,13 ----
 import unittest
 import dumbdbm
 from test import test_support
 
! _fname = test_support.TESTFN
 
 def _delete_files():
Index: test_gzip.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gzip.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_gzip.py	30 Jul 2002 23:26:01 -0000	1.10
--- test_gzip.py	9 Aug 2002 16:37:35 -0000	1.11
***************
*** 1,7 ****
! from test.test_support import verify
 import sys, os
! import gzip, tempfile
 
! filename = tempfile.mktemp()
 
 data1 = """ int length=DEFAULTALLOC, err = Z_OK;
--- 1,7 ----
! from test.test_support import verify, TESTFN
 import sys, os
! import gzip
 
! filename = TESTFN
 
 data1 = """ int length=DEFAULTALLOC, err = Z_OK;
Index: test_netrc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_netrc.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_netrc.py	23 Jul 2002 19:03:57 -0000	1.3
--- test_netrc.py	9 Aug 2002 16:37:35 -0000	1.4
***************
*** 1,4 ****
 
! import netrc, os, tempfile, unittest
 from test import test_support
 
--- 1,4 ----
 
! import netrc, os, unittest
 from test import test_support
 
***************
*** 18,22 ****
 """
 
! temp_filename = tempfile.mktemp()
 
 class NetrcTestCase(unittest.TestCase):
--- 18,22 ----
 """
 
! temp_filename = test_support.TESTFN
 
 class NetrcTestCase(unittest.TestCase):
Index: test_pkg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pkg.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_pkg.py	23 Jul 2002 19:03:58 -0000	1.15
--- test_pkg.py	9 Aug 2002 16:37:35 -0000	1.16
***************
*** 9,13 ****
 
 def mkhier(root, descr):
! mkdir(root)
 for name, contents in descr:
 comps = name.split()
--- 9,14 ----
 
 def mkhier(root, descr):
! if not os.path.isdir(root):
! mkdir(root)
 for name, contents in descr:
 comps = name.split()
***************
*** 53,68 ****
 
 def runtest(hier, code):
! root = tempfile.mktemp()
 mkhier(root, hier)
 savepath = sys.path[:]
! codefile = tempfile.mktemp()
! f = open(codefile, "w")
! f.write(code)
! f.close()
 try:
 sys.path.insert(0, root)
 if verbose: print "sys.path =", sys.path
 try:
! execfile(codefile, globals(), {})
 except:
 traceback.print_exc(file=sys.stdout)
--- 54,68 ----
 
 def runtest(hier, code):
! root = tempfile.mkdtemp()
 mkhier(root, hier)
 savepath = sys.path[:]
! codefile = tempfile.NamedTemporaryFile()
! codefile.write(code)
! codefile.flush()
 try:
 sys.path.insert(0, root)
 if verbose: print "sys.path =", sys.path
 try:
! execfile(codefile.name, globals(), {})
 except:
 traceback.print_exc(file=sys.stdout)
***************
*** 73,77 ****
 except (os.error, IOError):
 pass
- os.remove(codefile)
 
 # Test descriptions
--- 73,76 ----
Index: test_pkgimport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pkgimport.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_pkgimport.py	23 Jul 2002 19:03:58 -0000	1.6
--- test_pkgimport.py	9 Aug 2002 16:37:36 -0000	1.7
***************
*** 18,23 ****
 
 def setUp(self):
! self.test_dir = tempfile.mktemp()
! os.mkdir(self.test_dir)
 sys.path.append(self.test_dir)
 self.package_dir = os.path.join(self.test_dir,
--- 18,22 ----
 
 def setUp(self):
! self.test_dir = tempfile.mkdtemp()
 sys.path.append(self.test_dir)
 self.package_dir = os.path.join(self.test_dir,
Index: test_uu.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_uu.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_uu.py	23 Jul 2002 19:04:09 -0000	1.4
--- test_uu.py	9 Aug 2002 16:37:36 -0000	1.5
***************
*** 125,130 ****
 
 # Test to verify that decode() will refuse to overwrite an existing file
! import tempfile
! outfile = tempfile.mktemp()
 inp = StringIO('Here is a message to be uuencoded')
 out = StringIO()
--- 125,129 ----
 
 # Test to verify that decode() will refuse to overwrite an existing file
! outfile = TESTFN + "out"
 inp = StringIO('Here is a message to be uuencoded')
 out = StringIO()
Index: test_wave.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_wave.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_wave.py	23 Jul 2002 19:04:09 -0000	1.3
--- test_wave.py	9 Aug 2002 16:37:36 -0000	1.4
***************
*** 1,4 ****
! from test.test_support import TestFailed
! import os, tempfile
 import wave
 
--- 1,4 ----
! from test.test_support import TestFailed, TESTFN
! import os
 import wave
 
***************
*** 12,18 ****
 nframes = 100
 
! testfile = tempfile.mktemp()
! 
! f = wave.open(testfile, 'wb')
 f.setnchannels(nchannels)
 f.setsampwidth(sampwidth)
--- 12,16 ----
 nframes = 100
 
! f = wave.open(TESTFN, 'wb')
 f.setnchannels(nchannels)
 f.setsampwidth(sampwidth)
***************
*** 23,27 ****
 f.close()
 
! f = wave.open(testfile, 'rb')
 check(nchannels == f.getnchannels(), "nchannels")
 check(sampwidth == f.getsampwidth(), "sampwidth")
--- 21,25 ----
 f.close()
 
! f = wave.open(TESTFN, 'rb')
 check(nchannels == f.getnchannels(), "nchannels")
 check(sampwidth == f.getsampwidth(), "sampwidth")
***************
*** 32,34 ****
 f.close()
 
! os.remove(testfile)
--- 30,32 ----
 f.close()
 
! os.remove(TESTFN)
Index: test_whichdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_whichdb.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_whichdb.py	8 Aug 2002 20:19:19 -0000	1.2
--- test_whichdb.py	9 Aug 2002 16:37:36 -0000	1.3
***************
*** 12,16 ****
 import glob
 
! _fname = tempfile.mktemp()
 
 def _delete_files():
--- 12,16 ----
 import glob
 
! _fname = test.test_support.TESTFN
 
 def _delete_files():

AltStyle によって変換されたページ (->オリジナル) /