aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/entries-v10615
-rw-r--r--setuptools/tests/test_easy_install.py60
-rw-r--r--setuptools/tests/test_egg_info.py40
-rw-r--r--setuptools/tests/test_packageindex.py20
-rw-r--r--setuptools/tests/test_resources.py51
5 files changed, 686 insertions, 100 deletions
diff --git a/setuptools/tests/entries-v10 b/setuptools/tests/entries-v10
new file mode 100644
index 00000000..4446c501
--- /dev/null
+++ b/setuptools/tests/entries-v10
@@ -0,0 +1,615 @@
+10
+
+dir
+89001
+http://svn.python.org/projects/sandbox/branches/setuptools-0.6
+http://svn.python.org/projects
+
+
+
+2013-06-03T17:26:03.052972Z
+89000
+phillip.eby
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6015fed2-1504-0410-9fe1-9d1591cc4771
+
+api_tests.txt
+file
+
+
+
+
+2013-06-19T13:20:47.948712Z
+dec366372ca14fbeaeb26f492bcf5725
+2013-05-15T22:04:59.389374Z
+88997
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12312
+
+setuptools.egg-info
+dir
+
+README.txt
+file
+
+
+
+
+2013-06-19T13:20:47.948712Z
+26f0dd5d095522ba3ad999b6b6777b92
+2011-05-31T20:10:56.416725Z
+88846
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7615
+
+easy_install.py
+file
+
+
+
+
+2013-06-19T13:20:47.948712Z
+97b52fe7253bf4683f9f626f015eb72e
+2006-09-20T20:48:18.716070Z
+51935
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+126
+
+setuptools
+dir
+
+launcher.c
+file
+
+
+
+
+2013-06-19T13:20:47.924700Z
+e5a8e77de9022688b80f77fc6d742fee
+2009-10-19T21:03:29.785400Z
+75544
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7476
+
+ez_setup.py
+file
+
+
+
+
+2013-06-19T13:20:47.924700Z
+17e8ec5e08faccfcb08b5f8d5167ca14
+2011-01-20T18:50:00.815420Z
+88124
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8350
+
+version
+file
+
+
+
+
+2013-06-19T13:20:47.924700Z
+e456da09e0c9e224a56302f8316b6dbf
+2007-01-09T19:21:05.921317Z
+53317
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1143
+
+setup.py
+file
+
+
+
+
+2013-06-19T13:20:47.924700Z
+d4e5b3c16bd61bfef6c0bb9377a3a3ea
+2013-05-15T22:04:59.389374Z
+88997
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5228
+
+release.sh
+file
+
+
+
+
+2013-06-19T13:20:47.932704Z
+b1fd4054a1c107ff0f27baacd97be94c
+2009-10-28T17:12:45.227140Z
+75925
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1044
+
+pkg_resources.txt
+file
+
+
+
+
+2013-06-19T13:20:47.928702Z
+f497e7c92a4de207cbd9ab1943f93388
+2009-10-12T20:00:02.336146Z
+75385
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+94518
+
+site.py
+file
+
+
+
+
+2013-06-19T13:20:47.932704Z
+ebaac6fb6525f77ca950d22e6f8315df
+2006-03-11T00:39:09.666740Z
+42965
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2362
+
+version.dat
+file
+
+
+
+
+2013-06-19T13:20:47.932704Z
+8e14ecea32b9874cd7d29277494554c0
+2009-10-28T17:12:45.227140Z
+75925
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+80
+
+virtual-python.py
+file
+
+
+
+
+2013-06-19T13:20:47.932704Z
+aa857add3b5563238f0a904187f5ded9
+2005-10-17T02:26:39.000000Z
+41262
+pje
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3898
+
+setup.cfg
+file
+
+
+
+
+2013-06-19T13:20:47.932704Z
+eda883e744fce83f8107ad8dc8303536
+2006-09-21T22:26:48.050256Z
+51965
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+296
+
+setuptools.txt
+file
+
+
+
+
+2013-06-19T13:20:47.940708Z
+11926256f06046b196eaf814772504e7
+2013-05-15T22:04:59.389374Z
+88997
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+149832
+
+pkg_resources.py
+file
+
+
+
+
+2013-06-19T13:20:47.940708Z
+b63a30f5f0f0225a788c2c0e3430b3cf
+2013-05-15T22:04:59.389374Z
+88997
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+90397
+
+tests
+dir
+
+wikiup.cfg
+file
+
+
+
+
+2013-06-19T13:20:47.944710Z
+34ad845a5e0a0b46458557fa910bf429
+2008-08-21T17:23:50.797633Z
+65935
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+136
+
+EasyInstall.txt
+file
+
+
+
+
+2013-06-19T13:20:47.944710Z
+e97387c517f70fc18a377e42d19d64d4
+2013-05-15T22:04:59.389374Z
+88997
+phillip.eby
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+82495
+
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 582219ce..d17a5340 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -13,7 +13,7 @@ import StringIO
import distutils.core
from setuptools.sandbox import run_setup, SandboxViolation
-from setuptools.command.easy_install import easy_install, fix_jython_executable, get_script_args, main
+from setuptools.command.easy_install import easy_install, fix_jython_executable, get_script_args
from setuptools.command.easy_install import PthDistributions
from setuptools.command import easy_install as easy_install_pkg
from setuptools.dist import Distribution
@@ -84,41 +84,6 @@ class TestEasyInstallTest(unittest.TestCase):
self.assertEqual(script, WANTED)
- def test_no_setup_cfg(self):
- # makes sure easy_install as a command (main)
- # doesn't use a setup.cfg file that is located
- # in the current working directory
- dir = tempfile.mkdtemp()
- setup_cfg = open(os.path.join(dir, 'setup.cfg'), 'w')
- setup_cfg.write('[easy_install]\nfind_links = http://example.com')
- setup_cfg.close()
- setup_py = open(os.path.join(dir, 'setup.py'), 'w')
- setup_py.write(SETUP_PY)
- setup_py.close()
-
- from setuptools.dist import Distribution
-
- def _parse_command_line(self):
- msg = 'Error: a local setup.cfg was used'
- opts = self.command_options
- if 'easy_install' in opts:
- assert 'find_links' not in opts['easy_install'], msg
- return self._old_parse_command_line()
-
- Distribution._old_parse_command_line = Distribution.parse_command_line
- Distribution.parse_command_line = _parse_command_line
-
- old_wd = os.getcwd()
- try:
- os.chdir(dir)
- reset_setup_stop_context(
- lambda: self.assertRaises(SystemExit, main, [])
- )
- finally:
- os.chdir(old_wd)
- shutil.rmtree(dir)
- Distribution.parse_command_line = Distribution._old_parse_command_line
-
def test_no_find_links(self):
# new option '--no-find-links', that blocks find-links added at
# the project level
@@ -266,10 +231,10 @@ class TestUserInstallTest(unittest.TestCase):
del os.environ['PYTHONPATH']
def test_setup_requires(self):
- """Regression test for issue #318
+ """Regression test for Distribute issue #318
- Ensures that a package with setup_requires can be installed when
- distribute is installed in the user site-packages without causing a
+ Ensure that a package with setup_requires can be installed when
+ setuptools is installed in the user site-packages without causing a
SandboxViolation.
"""
@@ -307,11 +272,12 @@ class TestUserInstallTest(unittest.TestCase):
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
try:
- reset_setup_stop_context(
- lambda: run_setup(test_setup_py, ['install'])
- )
- except SandboxViolation:
- self.fail('Installation caused SandboxViolation')
+ try:
+ reset_setup_stop_context(
+ lambda: run_setup(test_setup_py, ['install'])
+ )
+ except SandboxViolation:
+ self.fail('Installation caused SandboxViolation')
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr
@@ -373,13 +339,13 @@ class TestSetupRequires(unittest.TestCase):
doesn't exist) and invoke installer on it.
"""
def build_sdist(dir):
- dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz')
+ dist_path = os.path.join(dir, 'setuptools-test-fetcher-1.0.tar.gz')
make_trivial_sdist(
dist_path,
textwrap.dedent("""
import setuptools
setuptools.setup(
- name="distribute-test-fetcher",
+ name="setuptools-test-fetcher",
version="1.0",
setup_requires = ['does-not-exist'],
)
@@ -447,7 +413,7 @@ def argv_context(f, repl):
def reset_setup_stop_context(f):
"""
- When the distribute tests are run using setup.py test, and then
+ When the setuptools tests are run using setup.py test, and then
one wants to invoke another setup() command (such as easy_install)
within those tests, it's necessary to reset the global variable
in distutils.core so that the setup() command will run naturally.
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
new file mode 100644
index 00000000..f26a1f51
--- /dev/null
+++ b/setuptools/tests/test_egg_info.py
@@ -0,0 +1,40 @@
+import os
+import tempfile
+import shutil
+import unittest
+
+import pkg_resources
+from setuptools.command import egg_info
+
+ENTRIES_V10 = pkg_resources.resource_string(__name__, 'entries-v10')
+"An entries file generated with svn 1.6.17 against the legacy Setuptools repo"
+
+class TestEggInfo(unittest.TestCase):
+
+ def setUp(self):
+ self.test_dir = tempfile.mkdtemp()
+ os.mkdir(os.path.join(self.test_dir, '.svn'))
+
+ self.old_cwd = os.getcwd()
+ os.chdir(self.test_dir)
+
+ def tearDown(self):
+ os.chdir(self.old_cwd)
+ shutil.rmtree(self.test_dir)
+
+ def _write_entries(self, entries):
+ fn = os.path.join(self.test_dir, '.svn', 'entries')
+ entries_f = open(fn, 'wb')
+ entries_f.write(entries)
+ entries_f.close()
+
+ def test_version_10_format(self):
+ """
+ """
+ self._write_entries(ENTRIES_V10)
+ rev = egg_info.egg_info.get_svn_revision()
+ self.assertEqual(rev, '89000')
+
+
+def test_suite():
+ return unittest.defaultTestLoader.loadTestsFromName(__name__)
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 3e446b54..1060e787 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -46,18 +46,14 @@ class TestPackageIndex(unittest.TestCase):
import httplib
raise httplib.BadStatusLine('line')
- old_urlopen = urllib2.urlopen
- urllib2.urlopen = _urlopen
+ index.opener = _urlopen
url = 'http://example.com'
try:
- try:
- v = index.open_url(url)
- except Exception, v:
- self.assertTrue('line' in str(v))
- else:
- raise AssertionError('Should have raise here!')
- finally:
- urllib2.urlopen = old_urlopen
+ v = index.open_url(url)
+ except Exception, v:
+ self.assertTrue('line' in str(v))
+ else:
+ raise AssertionError('Should have raise here!')
def test_bad_url_double_scheme(self):
"""
@@ -101,7 +97,7 @@ class TestPackageIndex(unittest.TestCase):
"""
Download links from the pypi simple index should be used before
external download links.
- http://bitbucket.org/tarek/distribute/issue/163/md5-validation-error
+ https://bitbucket.org/tarek/distribute/issue/163
Usecase :
- someone uploads a package on pypi, a md5 is generated
@@ -110,7 +106,7 @@ class TestPackageIndex(unittest.TestCase):
- someone reuploads the package (with a different md5)
- while easy_installing, an MD5 error occurs because the external link
is used
- -> Distribute should use the link from pypi, not the external one.
+ -> Setuptools should use the link from pypi, not the external one.
"""
if sys.platform.startswith('java'):
# Skip this test on jython because binding to :0 fails
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 292b78d1..34e341b5 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -197,29 +197,6 @@ class DistroTests(TestCase):
)
self.assertRaises(UnknownExtra, d.requires, ["foo"])
- def testSetuptoolsDistributeCombination(self):
- # Ensure that installing a 0.7-series setuptools fails. PJE says that
- # it will not co-exist.
- ws = WorkingSet([])
- d = Distribution(
- "/some/path",
- project_name="setuptools",
- version="0.7a1")
- self.assertRaises(ValueError, ws.add, d)
- # A 0.6-series is no problem
- d2 = Distribution(
- "/some/path",
- project_name="setuptools",
- version="0.6c9")
- ws.add(d2)
-
- # a unexisting version needs to work
- ws = WorkingSet([])
- d3 = Distribution(
- "/some/path",
- project_name="setuptools")
- ws.add(d3)
-
class EntryPointTests(TestCase):
@@ -372,21 +349,13 @@ class RequirementsTests(TestCase):
self.assertTrue(d("foo-0.3a3.egg") in r2)
self.assertTrue(d("foo-0.3a5.egg") in r2)
- def testDistributeSetuptoolsOverride(self):
- # Plain setuptools or distribute mean we return distribute.
- self.assertEqual(
- Requirement.parse('setuptools').project_name, 'distribute')
- self.assertEqual(
- Requirement.parse('distribute').project_name, 'distribute')
- # setuptools lower than 0.7 means distribute
- self.assertEqual(
- Requirement.parse('setuptools==0.6c9').project_name, 'distribute')
- self.assertEqual(
- Requirement.parse('setuptools==0.6c10').project_name, 'distribute')
- self.assertEqual(
- Requirement.parse('setuptools>=0.6').project_name, 'distribute')
+ def testSetuptoolsProjectName(self):
+ """
+ The setuptools project should implement the setuptools package.
+ """
+
self.assertEqual(
- Requirement.parse('setuptools < 0.7').project_name, 'distribute')
+ Requirement.parse('setuptools').project_name, 'setuptools')
# setuptools 0.7 and higher means setuptools.
self.assertEqual(
Requirement.parse('setuptools == 0.7').project_name, 'setuptools')
@@ -558,7 +527,7 @@ class ScriptHeaderTests(TestCase):
platform = sys.platform
sys.platform = 'java1.5.0_13'
- stdout = sys.stdout
+ stdout, stderr = sys.stdout, sys.stderr
try:
# A mock sys.executable that uses a shebang line (this file)
exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
@@ -581,7 +550,7 @@ class ScriptHeaderTests(TestCase):
finally:
del sys.modules["java"]
sys.platform = platform
- sys.stdout = stdout
+ sys.stdout, sys.stderr = stdout, stderr
@@ -590,7 +559,7 @@ class NamespaceTests(TestCase):
def setUp(self):
self._ns_pkgs = pkg_resources._namespace_packages.copy()
- self._tmpdir = tempfile.mkdtemp(prefix="tests-distribute-")
+ self._tmpdir = tempfile.mkdtemp(prefix="tests-setuptools-")
os.makedirs(os.path.join(self._tmpdir, "site-pkgs"))
self._prev_sys_path = sys.path[:]
sys.path.append(os.path.join(self._tmpdir, "site-pkgs"))
@@ -634,7 +603,7 @@ class NamespaceTests(TestCase):
try:
import pkg1.pkg2
except ImportError, e:
- self.fail("Distribute tried to import the parent namespace package")
+ self.fail("Setuptools tried to import the parent namespace package")
# check the _namespace_packages dict
self._assertIn("pkg1.pkg2", pkg_resources._namespace_packages.keys())
self.assertEqual(pkg_resources._namespace_packages["pkg1"], ["pkg1.pkg2"])