コード例 #1
0
ファイル: __init__.py プロジェクト: Basis/pip
 def run(self, *args, **kw):
     if self.verbose:
         print('>> running %s %s' % (args, kw))
     cwd = kw.pop('cwd', None)
     run_from = kw.pop('run_from', None)
     assert not cwd or not run_from, "Don't use run_from; it's going away"
     cwd = Path.string(cwd or run_from or self.cwd)
     assert not isinstance(cwd, Path)
     return TestPipResult(super(TestPipEnvironment, self).run(cwd=cwd, *args, **kw), verbose=self.verbose)
コード例 #2
0
 def run(self, *args, **kw):
     if self.verbose:
         print('>> running %s %s' % (args, kw))
     cwd = kw.pop('cwd', None)
     run_from = kw.pop('run_from', None)
     assert not cwd or not run_from, "Don't use run_from; it's going away"
     cwd = Path.string(cwd or run_from or self.cwd)
     assert not isinstance(cwd, Path)
     return TestPipResult(super(TestPipEnvironment, self).run(cwd=cwd,
                                                              *args,
                                                              **kw),
                          verbose=self.verbose)
コード例 #3
0
ファイル: __init__.py プロジェクト: Basis/pip
    def assert_installed(self, pkg_name, editable=True, with_files=[], without_files=[], without_egg_link=False, use_user_site=False):
        e = self.test_env

        if editable:
            pkg_dir = e.venv/ 'src'/ pkg_name.lower()
        else:
            without_egg_link = True
            pkg_dir = e.site_packages / pkg_name

        if use_user_site:
            egg_link_path = e.user_site / pkg_name + '.egg-link'
        else:
            egg_link_path = e.site_packages / pkg_name + '.egg-link'
        if without_egg_link:
            if egg_link_path in self.files_created:
                raise TestFailure('unexpected egg link file created: '\
                                  '%r\n%s' % (egg_link_path, self))
        else:
            if not egg_link_path in self.files_created:
                raise TestFailure('expected egg link file missing: '\
                                  '%r\n%s' % (egg_link_path, self))

            egg_link_file = self.files_created[egg_link_path]

            if not (# FIXME: I don't understand why there's a trailing . here
                    egg_link_file.bytes.endswith('.')
                and egg_link_file.bytes[:-1].strip().endswith(pkg_dir)):
                raise TestFailure(textwrap.dedent(u('''\
                Incorrect egg_link file %r
                Expected ending: %r
                ------- Actual contents -------
                %s
                -------------------------------''' % (
                        egg_link_file,
                        pkg_dir + u('\n.'),
                        egg_link_file.bytes))))

        if use_user_site:
            pth_file = Path.string(e.user_site / 'easy-install.pth')
        else:
            pth_file = Path.string(e.site_packages / 'easy-install.pth')

        if (pth_file in self.files_updated) == without_egg_link:
            raise TestFailure('%r unexpectedly %supdated by install' % (
                pth_file, (not without_egg_link and 'not ' or '')))

        if (pkg_dir in self.files_created) == (curdir in without_files):
            raise TestFailure(textwrap.dedent('''\
            expected package directory %r %sto be created
            actually created:
            %s
            ''') % (
                Path.string(pkg_dir),
                (curdir in without_files and 'not ' or ''),
                sorted(self.files_created.keys())))

        for f in with_files:
            if not (pkg_dir/f).normpath in self.files_created:
                raise TestFailure('Package directory %r missing '\
                                  'expected content %f' % (pkg_dir, f))

        for f in without_files:
            if (pkg_dir/f).normpath in self.files_created:
                raise TestFailure('Package directory %r has '\
                                  'unexpected content %f' % (pkg_dir, f))
コード例 #4
0
    def assert_installed(self,
                         pkg_name,
                         editable=True,
                         with_files=[],
                         without_files=[],
                         without_egg_link=False,
                         use_user_site=False):
        e = self.test_env

        if editable:
            pkg_dir = e.venv / 'src' / pkg_name.lower()
        else:
            without_egg_link = True
            pkg_dir = e.site_packages / pkg_name

        if use_user_site:
            egg_link_path = e.user_site / pkg_name + '.egg-link'
        else:
            egg_link_path = e.site_packages / pkg_name + '.egg-link'
        if without_egg_link:
            if egg_link_path in self.files_created:
                raise TestFailure('unexpected egg link file created: '\
                                  '%r\n%s' % (egg_link_path, self))
        else:
            if not egg_link_path in self.files_created:
                raise TestFailure('expected egg link file missing: '\
                                  '%r\n%s' % (egg_link_path, self))

            egg_link_file = self.files_created[egg_link_path]

            if not (  # FIXME: I don't understand why there's a trailing . here
                    egg_link_file.bytes.endswith('.')
                    and egg_link_file.bytes[:-1].strip().endswith(pkg_dir)):
                raise TestFailure(
                    textwrap.dedent(
                        u('''\
                Incorrect egg_link file %r
                Expected ending: %r
                ------- Actual contents -------
                %s
                -------------------------------''' %
                          (egg_link_file, pkg_dir + u('\n.'),
                           egg_link_file.bytes))))

        if use_user_site:
            pth_file = Path.string(e.user_site / 'easy-install.pth')
        else:
            pth_file = Path.string(e.site_packages / 'easy-install.pth')

        if (pth_file in self.files_updated) == without_egg_link:
            raise TestFailure('%r unexpectedly %supdated by install' %
                              (pth_file,
                               (not without_egg_link and 'not ' or '')))

        if (pkg_dir in self.files_created) == (curdir in without_files):
            raise TestFailure(
                textwrap.dedent('''\
            expected package directory %r %sto be created
            actually created:
            %s
            ''') % (Path.string(pkg_dir),
                    (curdir in without_files and 'not '
                     or ''), sorted(self.files_created.keys())))

        for f in with_files:
            if not (pkg_dir / f).normpath in self.files_created:
                raise TestFailure('Package directory %r missing '\
                                  'expected content %f' % (pkg_dir, f))

        for f in without_files:
            if (pkg_dir / f).normpath in self.files_created:
                raise TestFailure('Package directory %r has '\
                                  'unexpected content %f' % (pkg_dir, f))