From c49ceeb20b4478dcd089be4f1ebe1684fb880bb5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 19 Mar 2013 12:06:28 -0700 Subject: Update test_distribute_setup to reference ez_setup.py --HG-- branch : Setuptools-Distribute merge rename : tests/test_distribute_setup.py => tests/test_ez_setup.py extra : rebase_source : d6fe218013147bd6a4e43220356d539d7764da11 --- tests/test_distribute_setup.py | 73 ------------------------------------------ tests/test_ez_setup.py | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 73 deletions(-) delete mode 100644 tests/test_distribute_setup.py create mode 100644 tests/test_ez_setup.py diff --git a/tests/test_distribute_setup.py b/tests/test_distribute_setup.py deleted file mode 100644 index 1f3da058..00000000 --- a/tests/test_distribute_setup.py +++ /dev/null @@ -1,73 +0,0 @@ -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, - DEFAULT_VERSION) -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() - os.chdir(TOPDIR) - _python_cmd("setup.py", "-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): - shutil.rmtree(self.tmpdir) - os.chdir(self.cwd) - 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 - self.assertTrue(setuptools.__file__.startswith(egg)) - - def test_do_download(self): - tmpdir = tempfile.mkdtemp() - _do_download(DEFAULT_VERSION, DEFAULT_URL, tmpdir, 1) - import setuptools - self.assertTrue(setuptools.bootstrap_install_from.startswith(tmpdir)) - - def test_install(self): - def _faked(*args): - return True - distribute_setup.python_cmd = _faked - _install(self.tarball) - - 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 - use_setuptools() - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_ez_setup.py b/tests/test_ez_setup.py new file mode 100644 index 00000000..922bd884 --- /dev/null +++ b/tests/test_ez_setup.py @@ -0,0 +1,63 @@ +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 ez_setup import (use_setuptools, _build_egg, _python_cmd, _do_download, + _install, DEFAULT_URL, DEFAULT_VERSION) +import ez_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() + os.chdir(TOPDIR) + _python_cmd("setup.py", "-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): + shutil.rmtree(self.tmpdir) + os.chdir(self.cwd) + 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 + self.assertTrue(setuptools.__file__.startswith(egg)) + + def test_do_download(self): + tmpdir = tempfile.mkdtemp() + _do_download(DEFAULT_VERSION, DEFAULT_URL, tmpdir, 1) + import setuptools + self.assertTrue(setuptools.bootstrap_install_from.startswith(tmpdir)) + + def test_install(self): + def _faked(*args): + return True + ez_setup.python_cmd = _faked + _install(self.tarball) + + def test_use_setuptools(self): + self.assertEqual(use_setuptools(), None) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3