summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-17 17:21:50 +0200
committerChris McDonough <chrism@plope.com>2013-08-17 17:21:50 +0200
commit8b1007d402cd8fb1ea3a35c5ad1dbc6616919a56 (patch)
tree6b5b9e7c388ba422811f2a7f06d217eec5f89352
parent2d66691349b5042a0316c3f051c3a6d7edddc4a1 (diff)
parent796af58e3741a03cbddbaed19def5984fe8601e4 (diff)
downloadpyramid-8b1007d402cd8fb1ea3a35c5ad1dbc6616919a56.tar.gz
pyramid-8b1007d402cd8fb1ea3a35c5ad1dbc6616919a56.tar.bz2
pyramid-8b1007d402cd8fb1ea3a35c5ad1dbc6616919a56.zip
Merge branch 'adroullier-master'
-rw-r--r--pyramid/scaffolds/copydir.py8
-rw-r--r--pyramid/tests/test_scaffolds/test_copydir.py47
2 files changed, 48 insertions, 7 deletions
diff --git a/pyramid/scaffolds/copydir.py b/pyramid/scaffolds/copydir.py
index ba0988523..7864dd1a1 100644
--- a/pyramid/scaffolds/copydir.py
+++ b/pyramid/scaffolds/copydir.py
@@ -90,16 +90,16 @@ def copy_dir(source, dest, vars, verbosity, simulate, indent=0,
if verbosity:
out('%sRecursing into %s' % (pad, os.path.basename(full)))
copy_dir((source[0], full), dest_full, vars, verbosity, simulate,
- indent=indent+1,
- sub_vars=sub_vars, interactive=interactive,
+ indent=indent+1, sub_vars=sub_vars,
+ interactive=interactive, overwrite=overwrite,
template_renderer=template_renderer, out_=out_)
continue
elif not use_pkg_resources and os.path.isdir(full):
if verbosity:
out('%sRecursing into %s' % (pad, os.path.basename(full)))
copy_dir(full, dest_full, vars, verbosity, simulate,
- indent=indent+1,
- sub_vars=sub_vars, interactive=interactive,
+ indent=indent+1, sub_vars=sub_vars,
+ interactive=interactive, overwrite=overwrite,
template_renderer=template_renderer, out_=out_)
continue
elif use_pkg_resources:
diff --git a/pyramid/tests/test_scaffolds/test_copydir.py b/pyramid/tests/test_scaffolds/test_copydir.py
index d757b837c..1e92b3c36 100644
--- a/pyramid/tests/test_scaffolds/test_copydir.py
+++ b/pyramid/tests/test_scaffolds/test_copydir.py
@@ -103,16 +103,57 @@ class Test_copy_dir(unittest.TestCase):
1, False,
overwrite=False,
template_renderer=dummy_template_renderer)
- target = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(target, 'w') as f:
- f.write('These are not the words you are looking for.')
+ # toplevel file
+ toplevel = os.path.join(self.dirname, 'mypackage', '__init__.py')
+ with open(toplevel, 'w') as f:
+ f.write('These are the words you are looking for.')
+ # sub directory file
+ sub = os.path.join(self.dirname, 'mypackage', 'templates', 'mytemplate.pt')
+ with open(sub, 'w') as f:
+ f.write('These are the words you are looking for.')
self._callFUT(source,
self.dirname,
vars,
1, False,
overwrite=False,
template_renderer=dummy_template_renderer)
+ with open(toplevel, 'r') as f:
+ tcontent = f.read()
+ self.assertEqual('These are the words you are looking for.', tcontent)
+ with open(sub, 'r') as f:
+ tcontent = f.read()
+ self.assertEqual('These are the words you are looking for.', tcontent)
+ def test_overwrite_true(self):
+ vars = {'package':'mypackage'}
+ source = pkg_resources.resource_filename(*self.fixturetuple)
+ self._callFUT(source,
+ self.dirname,
+ vars,
+ 1, False,
+ overwrite=True,
+ template_renderer=dummy_template_renderer)
+ # toplevel file
+ toplevel = os.path.join(self.dirname, 'mypackage', '__init__.py')
+ with open(toplevel, 'w') as f:
+ f.write('These are not the words you are looking for.')
+ # sub directory file
+ sub = os.path.join(self.dirname, 'mypackage', 'templates', 'mytemplate.pt')
+ with open(sub, 'w') as f:
+ f.write('These are not the words you are looking for.')
+ self._callFUT(source,
+ self.dirname,
+ vars,
+ 1, False,
+ overwrite=True,
+ template_renderer=dummy_template_renderer)
+ with open(toplevel, 'r') as f:
+ tcontent = f.read()
+ self.assertNotEqual('These are not the words you are looking for.', tcontent)
+ with open(sub, 'r') as f:
+ tcontent = f.read()
+ self.assertNotEqual('These are not the words you are looking for.', tcontent)
+
def test_detect_SkipTemplate(self):
vars = {'package':'mypackage'}
source = pkg_resources.resource_filename(*self.fixturetuple)