distribute / tests /

The branch 'default' does not exist.
import sys
import os
import tempfile
import unittest
import shutil
import copy

CURDIR = os.path.abspath(os.path.dirname(__file__))
TOPDIR = os.path.split(CURDIR)[0]
sys.path.insert(0, TOPDIR)

from distribute_setup import (use_setuptools, _build_egg, _python_cmd,
                              _do_download, _install, DEFAULT_URL,
import distribute_setup

class TestSetup(unittest.TestCase):

    def urlopen(self, url):
        return open(self.tarball)

    def setUp(self):
        self.old_sys_path = copy.copy(sys.path)
        self.cwd = os.getcwd()
        self.tmpdir = tempfile.mkdtemp()
        _python_cmd("", "-q", "egg_info", "-RDb", "''", "sdist",
                    "--dist-dir", "%s" % self.tmpdir)
        tarball = os.listdir(self.tmpdir)[0]
        self.tarball = os.path.join(self.tmpdir, tarball)
        import urllib2
        urllib2.urlopen = self.urlopen

    def tearDown(self):
        sys.path = copy.copy(self.old_sys_path)

    def test_build_egg(self):
        # making it an egg
        egg = _build_egg(self.tarball, self.tmpdir)

        # now trying to import it
        sys.path[0] = egg
        import setuptools

    def test_do_download(self):
        tmpdir = tempfile.mkdtemp()
        _do_download(DEFAULT_VERSION, DEFAULT_URL, tmpdir, 1)
        import setuptools

    def test_install(self):
        def _faked(*args):
            return True
        distribute_setup.python_cmd = _faked

    def test_use_setuptools(self):
        self.assertEqual(use_setuptools(), None)

        # make sure fake_setuptools is not called by default
        import pkg_resources
        del pkg_resources._distribute
        def fake_setuptools(*args):
            raise AssertionError

        pkg_resources._fake_setuptools = fake_setuptools

if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.