Make creation of temporary file and directory more portable. Also made cleanup
code use proper functions to get paths. Changed the name of tar file that is searched for to be absolute (i.e., not use os.extsep) since filename is locked in based on name of file in CVS (testtar.tar). Closes bug #731403 .
This commit is contained in:
parent
a4e5c4da4d
commit
455ea53d0e
|
@ -1,6 +1,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import tarfile
|
import tarfile
|
||||||
|
@ -21,9 +22,9 @@ except ImportError:
|
||||||
def path(path):
|
def path(path):
|
||||||
return test_support.findfile(path)
|
return test_support.findfile(path)
|
||||||
|
|
||||||
testtar = path("testtar" + os.extsep + "tar")
|
testtar = path("testtar.tar")
|
||||||
tempdir = path("testtar" + os.extsep + "dir")
|
tempdir = os.path.join(tempfile.gettempdir(), "testtar" + os.extsep + "dir")
|
||||||
tempname = path("testtar" + os.extsep + "tmp")
|
tempname = test_support.TESTFN
|
||||||
membercount = 10
|
membercount = 10
|
||||||
|
|
||||||
def tarname(comp=""):
|
def tarname(comp=""):
|
||||||
|
@ -265,10 +266,10 @@ def test_main():
|
||||||
os.remove(tarname("gz"))
|
os.remove(tarname("gz"))
|
||||||
if bz2:
|
if bz2:
|
||||||
os.remove(tarname("bz2"))
|
os.remove(tarname("bz2"))
|
||||||
if os.path.exists(tempdir):
|
if os.path.exists(dirname()):
|
||||||
shutil.rmtree(tempdir)
|
shutil.rmtree(dirname())
|
||||||
if os.path.exists(tempname):
|
if os.path.exists(tmpname()):
|
||||||
os.remove(tempname)
|
os.remove(tmpname())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main()
|
||||||
|
|
Loading…
Reference in New Issue