Chris McDonough
2013-08-17 8b1007d402cd8fb1ea3a35c5ad1dbc6616919a56
Merge branch 'adroullier-master'
2 files modified
55 ■■■■ changed files
pyramid/scaffolds/copydir.py 8 ●●●● patch | view | raw | blame | history
pyramid/tests/test_scaffolds/test_copydir.py 47 ●●●●● patch | view | raw | blame | history
pyramid/scaffolds/copydir.py
@@ -90,16 +90,16 @@
            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:
pyramid/tests/test_scaffolds/test_copydir.py
@@ -103,16 +103,57 @@
                      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)