summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests/test_sdist.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-02-14 14:35:51 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-02-14 14:35:51 (GMT)
commitc1375d5e0168450b7411227ad3b95286aa1d70b4 (patch)
treedc4ab4ce5a44dfe26d8d930aee2418b002d52863 /Lib/distutils/tests/test_sdist.py
parent9e8dbbcdcd462efc8f50008c7182dd399de89097 (diff)
downloadcpython-c1375d5e0168450b7411227ad3b95286aa1d70b4.zip
cpython-c1375d5e0168450b7411227ad3b95286aa1d70b4.tar.gz
cpython-c1375d5e0168450b7411227ad3b95286aa1d70b4.tar.bz2
Merged revisions 69609 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69609 | tarek.ziade | 2009-02-14 15:10:23 +0100 (Sat, 14 Feb 2009) | 1 line Fix for #5257: refactored all tests in distutils, so they use a temporary directory. ........
Diffstat (limited to 'Lib/distutils/tests/test_sdist.py')
-rw-r--r--Lib/distutils/tests/test_sdist.py50
1 files changed, 21 insertions, 29 deletions
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 0d839b5..b2e9800 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -5,6 +5,7 @@ import shutil
import zipfile
from os.path import join
import sys
+import tempfile
from distutils.command.sdist import sdist
from distutils.core import Distribution
@@ -12,9 +13,6 @@ from distutils.tests.test_config import PyPIRCCommandTestCase
from distutils.errors import DistutilsExecError
from distutils.spawn import find_executable
-CURDIR = os.path.dirname(__file__)
-TEMP_PKG = join(CURDIR, 'temppkg')
-
SETUP_PY = """
from distutils.core import setup
import somecode
@@ -29,28 +27,25 @@ recursive-include somecode *
class sdistTestCase(PyPIRCCommandTestCase):
def setUp(self):
+ # PyPIRCCommandTestCase creates a temp dir already
+ # and put it in self.tmp_dir
PyPIRCCommandTestCase.setUp(self)
+ # setting up an environment
self.old_path = os.getcwd()
+ os.mkdir(join(self.tmp_dir, 'somecode'))
+ os.mkdir(join(self.tmp_dir, 'dist'))
+ # creating a MANIFEST, a package, and a README
+ self._write(join(self.tmp_dir, 'MANIFEST.in'), MANIFEST_IN)
+ self._write(join(self.tmp_dir, 'README'), 'xxx')
+ self._write(join(self.tmp_dir, 'somecode', '__init__.py'), '#')
+ self._write(join(self.tmp_dir, 'setup.py'), SETUP_PY)
+ os.chdir(self.tmp_dir)
def tearDown(self):
+ # back to normal
os.chdir(self.old_path)
- if os.path.exists(TEMP_PKG):
- shutil.rmtree(TEMP_PKG)
PyPIRCCommandTestCase.tearDown(self)
- def _init_tmp_pkg(self):
- if os.path.exists(TEMP_PKG):
- shutil.rmtree(TEMP_PKG)
- os.mkdir(TEMP_PKG)
- os.mkdir(join(TEMP_PKG, 'somecode'))
- os.mkdir(join(TEMP_PKG, 'dist'))
- # creating a MANIFEST, a package, and a README
- self._write(join(TEMP_PKG, 'MANIFEST.in'), MANIFEST_IN)
- self._write(join(TEMP_PKG, 'README'), 'xxx')
- self._write(join(TEMP_PKG, 'somecode', '__init__.py'), '#')
- self._write(join(TEMP_PKG, 'setup.py'), SETUP_PY)
- os.chdir(TEMP_PKG)
-
def _write(self, path, content):
f = open(path, 'w')
try:
@@ -62,18 +57,17 @@ class sdistTestCase(PyPIRCCommandTestCase):
# this test creates a package with some vcs dirs in it
# and launch sdist to make sure they get pruned
# on all systems
- self._init_tmp_pkg()
# creating VCS directories with some files in them
- os.mkdir(join(TEMP_PKG, 'somecode', '.svn'))
- self._write(join(TEMP_PKG, 'somecode', '.svn', 'ok.py'), 'xxx')
+ os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
+ self._write(join(self.tmp_dir, 'somecode', '.svn', 'ok.py'), 'xxx')
- os.mkdir(join(TEMP_PKG, 'somecode', '.hg'))
- self._write(join(TEMP_PKG, 'somecode', '.hg',
+ os.mkdir(join(self.tmp_dir, 'somecode', '.hg'))
+ self._write(join(self.tmp_dir, 'somecode', '.hg',
'ok'), 'xxx')
- os.mkdir(join(TEMP_PKG, 'somecode', '.git'))
- self._write(join(TEMP_PKG, 'somecode', '.git',
+ os.mkdir(join(self.tmp_dir, 'somecode', '.git'))
+ self._write(join(self.tmp_dir, 'somecode', '.git',
'ok'), 'xxx')
# now building a sdist
@@ -96,7 +90,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
cmd.run()
# now let's check what we have
- dist_folder = join(TEMP_PKG, 'dist')
+ dist_folder = join(self.tmp_dir, 'dist')
files = os.listdir(dist_folder)
self.assertEquals(files, ['fake-1.0.zip'])
@@ -116,8 +110,6 @@ class sdistTestCase(PyPIRCCommandTestCase):
find_executable('gzip') is None):
return
- self._init_tmp_pkg()
-
# now building a sdist
dist = Distribution()
dist.script_name = 'setup.py'
@@ -137,7 +129,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
cmd.run()
# making sure we have two files
- dist_folder = join(TEMP_PKG, 'dist')
+ dist_folder = join(self.tmp_dir, 'dist')
result = os.listdir(dist_folder)
result.sort()
self.assertEquals(result,