diff options
| author | adroullier <arndt@nive.co> | 2013-08-17 11:58:02 +0200 |
|---|---|---|
| committer | adroullier <arndt@nive.co> | 2013-08-17 11:58:02 +0200 |
| commit | c138ce30a60199e1a82b2b4d5fbf1faaf9db9e70 (patch) | |
| tree | d392b0b0d243e787f4524d425f94b16ea13d3c96 | |
| parent | a5a8019b62ddc2f73a16799ac3107e22446a4c08 (diff) | |
| download | pyramid-c138ce30a60199e1a82b2b4d5fbf1faaf9db9e70.tar.gz pyramid-c138ce30a60199e1a82b2b4d5fbf1faaf9db9e70.tar.bz2 pyramid-c138ce30a60199e1a82b2b4d5fbf1faaf9db9e70.zip | |
copy_dir() recursive overwrite test updates
| -rw-r--r-- | pyramid/tests/test_scaffolds/test_copydir.py | 47 |
1 files changed, 44 insertions, 3 deletions
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) |
