summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorÉric Araujo <aeric@mtlpy.org>2012-12-08 19:21:51 (GMT)
committerÉric Araujo <aeric@mtlpy.org>2012-12-08 19:21:51 (GMT)
commit3e4a3dcb23d849fa0ce5f5009e83606abaef15aa (patch)
tree41475986d38a6d9ecdcacb93a3205a164137501f /Lib/distutils/tests
parent09974b4e9e8da3c9ba0469f4812e68cf9f700ffd (diff)
downloadcpython-3e4a3dcb23d849fa0ce5f5009e83606abaef15aa.zip
cpython-3e4a3dcb23d849fa0ce5f5009e83606abaef15aa.tar.gz
cpython-3e4a3dcb23d849fa0ce5f5009e83606abaef15aa.tar.bz2
Ignore .nfs* files in distutils (#7719).
These files are created by some NFS clients a file is edited and removed concurrently (see added link in doc for more info). If such a file is removed between distutils calls listdir and copy, it will get confused. Other special files are ignored in sdist (namely VCS directories), but this has to be filtered out earlier.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_dir_util.py21
-rw-r--r--Lib/distutils/tests/test_sdist.py7
2 files changed, 20 insertions, 8 deletions
diff --git a/Lib/distutils/tests/test_dir_util.py b/Lib/distutils/tests/test_dir_util.py
index ce74589..1589f12 100644
--- a/Lib/distutils/tests/test_dir_util.py
+++ b/Lib/distutils/tests/test_dir_util.py
@@ -76,7 +76,6 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
remove_tree(self.root_target, verbose=0)
-
def test_copy_tree_verbosity(self):
mkpath(self.target, verbose=0)
@@ -88,11 +87,8 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
mkpath(self.target, verbose=0)
a_file = os.path.join(self.target, 'ok.txt')
- f = open(a_file, 'w')
- try:
+ with open(a_file, 'w') as f:
f.write('some content')
- finally:
- f.close()
wanted = ['copying %s -> %s' % (a_file, self.target2)]
copy_tree(self.target, self.target2, verbose=1)
@@ -101,6 +97,21 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
remove_tree(self.root_target, verbose=0)
remove_tree(self.target2, verbose=0)
+ def test_copy_tree_skips_nfs_temp_files(self):
+ mkpath(self.target, verbose=0)
+
+ a_file = os.path.join(self.target, 'ok.txt')
+ nfs_file = os.path.join(self.target, '.nfs123abc')
+ for f in a_file, nfs_file:
+ with open(f, 'w') as fh:
+ fh.write('some content')
+
+ copy_tree(self.target, self.target2)
+ self.assertEqual(os.listdir(self.target2), ['ok.txt'])
+
+ remove_tree(self.root_target, verbose=0)
+ remove_tree(self.target2, verbose=0)
+
def test_ensure_relative(self):
if os.sep == '/':
self.assertEqual(ensure_relative('/home/foo'), 'home/foo')
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 1ba2a1a..e6359d6 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -83,9 +83,8 @@ class SDistTestCase(PyPIRCCommandTestCase):
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_prune_file_list(self):
- # this test creates a package with some vcs dirs in it
- # and launch sdist to make sure they get pruned
- # on all systems
+ # this test creates a project with some VCS dirs and an NFS rename
+ # file, then launches sdist to check they get pruned on all systems
# creating VCS directories with some files in them
os.mkdir(join(self.tmp_dir, 'somecode', '.svn'))
@@ -99,6 +98,8 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.write_file((self.tmp_dir, 'somecode', '.git',
'ok'), 'xxx')
+ self.write_file((self.tmp_dir, 'somecode', '.nfs0001'), 'xxx')
+
# now building a sdist
dist, cmd = self.get_cmd()