diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2013-07-02 12:06:51 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-07-02 12:06:51 -0400 |
| commit | 3df6f1d026a601c5c2bd2388c05725f28b38d12b (patch) | |
| tree | 03c83e6a2ee50f14a0478225186752aaf021399f /tests | |
| parent | f54ab032ee243dc5c412d3e583ff514715ebbd28 (diff) | |
| parent | 267a883298af4a51609ffc1354c86a4dac78936e (diff) | |
| download | python-setuptools-bitbucket-3df6f1d026a601c5c2bd2388c05725f28b38d12b.tar.gz | |
Merge
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/api_tests.txt | 6 | ||||
| -rw-r--r-- | tests/manual_test.py | 2 | ||||
| -rw-r--r-- | tests/test_ez_setup.py | 6 | ||||
| -rw-r--r-- | tests/test_pkg_resources.py | 110 |
4 files changed, 62 insertions, 62 deletions
diff --git a/tests/api_tests.txt b/tests/api_tests.txt index d03da14e..86ca245d 100644 --- a/tests/api_tests.txt +++ b/tests/api_tests.txt @@ -39,7 +39,7 @@ Distributions have various introspectable attributes:: >>> dist.py_version == sys.version[:3] True - >>> print dist.platform + >>> print(dist.platform) None Including various computed attributes:: @@ -199,7 +199,7 @@ shows up once when iterating the working set: You can ask a WorkingSet to ``find()`` a distribution matching a requirement:: >>> from pkg_resources import Requirement - >>> print ws.find(Requirement.parse("Foo==1.0")) # no match, return None + >>> print(ws.find(Requirement.parse("Foo==1.0"))) # no match, return None None >>> ws.find(Requirement.parse("Bar==0.9")) # match, return distribution @@ -222,7 +222,7 @@ distribution is added to a working set. The callback is immediately invoked once for each existing distribution in the working set, and then is called again for new distributions added thereafter:: - >>> def added(dist): print "Added", dist + >>> def added(dist): print("Added %s" % dist) >>> ws.subscribe(added) Added Bar 0.9 >>> foo12 = Distribution(project_name="Foo", version="1.2", location="f12") diff --git a/tests/manual_test.py b/tests/manual_test.py index 44cf2d06..3eab99e1 100644 --- a/tests/manual_test.py +++ b/tests/manual_test.py @@ -9,7 +9,7 @@ import shutil import tempfile from distutils.command.install import INSTALL_SCHEMES from string import Template -from urllib2 import urlopen +from setuptools.compat import urlopen try: import subprocess diff --git a/tests/test_ez_setup.py b/tests/test_ez_setup.py index 922bd884..26881f52 100644 --- a/tests/test_ez_setup.py +++ b/tests/test_ez_setup.py @@ -16,7 +16,7 @@ import ez_setup class TestSetup(unittest.TestCase): def urlopen(self, url): - return open(self.tarball) + return open(self.tarball, 'rb') def setUp(self): self.old_sys_path = copy.copy(sys.path) @@ -27,7 +27,7 @@ class TestSetup(unittest.TestCase): "--dist-dir", "%s" % self.tmpdir) tarball = os.listdir(self.tmpdir)[0] self.tarball = os.path.join(self.tmpdir, tarball) - import urllib2 + from setuptools.compat import urllib2 urllib2.urlopen = self.urlopen def tearDown(self): @@ -37,7 +37,7 @@ class TestSetup(unittest.TestCase): def test_build_egg(self): # making it an egg - egg = _build_egg(self.tarball, self.tmpdir) + egg = _build_egg('Egg to be built', self.tarball, self.tmpdir) # now trying to import it sys.path[0] = egg diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py index f3256173..398f1acc 100644 --- a/tests/test_pkg_resources.py +++ b/tests/test_pkg_resources.py @@ -6,69 +6,69 @@ import zipfile import pkg_resources try: - unicode + unicode except NameError: - unicode = str + unicode = str class EggRemover(unicode): - def __call__(self): - if self in sys.path: - sys.path.remove(self) - if os.path.exists(self): - os.remove(self) + def __call__(self): + if self in sys.path: + sys.path.remove(self) + if os.path.exists(self): + os.remove(self) class TestZipProvider(object): - finalizers = [] + finalizers = [] - @classmethod - def setup_class(cls): - "create a zip egg and add it to sys.path" - egg = tempfile.NamedTemporaryFile(suffix='.egg', delete=False) - zip_egg = zipfile.ZipFile(egg, 'w') - zip_info = zipfile.ZipInfo() - zip_info.filename = 'mod.py' - zip_info.date_time = 2013, 5, 12, 13, 25, 0 - zip_egg.writestr(zip_info, 'x = 3\n') - zip_info = zipfile.ZipInfo() - zip_info.filename = 'data.dat' - zip_info.date_time = 2013, 5, 12, 13, 25, 0 - zip_egg.writestr(zip_info, 'hello, world!') - zip_egg.close() - egg.close() + @classmethod + def setup_class(cls): + "create a zip egg and add it to sys.path" + egg = tempfile.NamedTemporaryFile(suffix='.egg', delete=False) + zip_egg = zipfile.ZipFile(egg, 'w') + zip_info = zipfile.ZipInfo() + zip_info.filename = 'mod.py' + zip_info.date_time = 2013, 5, 12, 13, 25, 0 + zip_egg.writestr(zip_info, 'x = 3\n') + zip_info = zipfile.ZipInfo() + zip_info.filename = 'data.dat' + zip_info.date_time = 2013, 5, 12, 13, 25, 0 + zip_egg.writestr(zip_info, 'hello, world!') + zip_egg.close() + egg.close() - sys.path.append(egg.name) - cls.finalizers.append(EggRemover(egg.name)) + sys.path.append(egg.name) + cls.finalizers.append(EggRemover(egg.name)) - @classmethod - def teardown_class(cls): - for finalizer in cls.finalizers: - finalizer() + @classmethod + def teardown_class(cls): + for finalizer in cls.finalizers: + finalizer() - def test_resource_filename_rewrites_on_change(self): - """ - If a previous call to get_resource_filename has saved the file, but - the file has been subsequently mutated with different file of the - same size and modification time, it should not be overwritten on a - subsequent call to get_resource_filename. - """ - import mod - manager = pkg_resources.ResourceManager() - zp = pkg_resources.ZipProvider(mod) - filename = zp.get_resource_filename(manager, 'data.dat') - assert os.stat(filename).st_mtime == 1368379500 - f = open(filename, 'wb') - f.write('hello, world?') - f.close() - os.utime(filename, (1368379500, 1368379500)) - filename = zp.get_resource_filename(manager, 'data.dat') - f = open(filename) - assert f.read() == 'hello, world!' - manager.cleanup_resources() + def test_resource_filename_rewrites_on_change(self): + """ + If a previous call to get_resource_filename has saved the file, but + the file has been subsequently mutated with different file of the + same size and modification time, it should not be overwritten on a + subsequent call to get_resource_filename. + """ + import mod + manager = pkg_resources.ResourceManager() + zp = pkg_resources.ZipProvider(mod) + filename = zp.get_resource_filename(manager, 'data.dat') + assert os.stat(filename).st_mtime == 1368379500 + f = open(filename, 'wb') + f.write('hello, world?') + f.close() + os.utime(filename, (1368379500, 1368379500)) + filename = zp.get_resource_filename(manager, 'data.dat') + f = open(filename) + assert f.read() == 'hello, world!' + manager.cleanup_resources() class TestResourceManager(object): - def test_get_cache_path(self): - mgr = pkg_resources.ResourceManager() - path = mgr.get_cache_path('foo') - type_ = str(type(path)) - message = "Unexpected type from get_cache_path: " + type_ - assert isinstance(path, (unicode, str)), message + def test_get_cache_path(self): + mgr = pkg_resources.ResourceManager() + path = mgr.get_cache_path('foo') + type_ = str(type(path)) + message = "Unexpected type from get_cache_path: " + type_ + assert isinstance(path, (unicode, str)), message |
