From 1bc7b7b3dd81a74d4be2bc0c4e95ba8d29dc58d9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2013 11:55:26 -0400 Subject: Issue #30: Added test for get_cache_path (but it doesn't yet get run) --- tests/test_pkg_resources.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_pkg_resources.py') diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py index 7009b4ab..6e4a9348 100644 --- a/tests/test_pkg_resources.py +++ b/tests/test_pkg_resources.py @@ -59,3 +59,11 @@ class TestZipProvider(object): 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 -- cgit v1.2.1 From 178a4ab5c3af80c077572fd01d748084b35844e0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2013 12:00:35 -0400 Subject: Patched test so it can be run on Python 3 --- tests/test_pkg_resources.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/test_pkg_resources.py') diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py index 6e4a9348..f3256173 100644 --- a/tests/test_pkg_resources.py +++ b/tests/test_pkg_resources.py @@ -5,6 +5,11 @@ import zipfile import pkg_resources +try: + unicode +except NameError: + unicode = str + class EggRemover(unicode): def __call__(self): if self in sys.path: -- cgit v1.2.1 From 78c3e6b7b3a12d74416f43995d50b04bdb817f0b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Jul 2013 12:08:16 -0400 Subject: Fix test failure --- tests/test_pkg_resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_pkg_resources.py') diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py index 398f1acc..dfa27120 100644 --- a/tests/test_pkg_resources.py +++ b/tests/test_pkg_resources.py @@ -56,7 +56,7 @@ class TestZipProvider(object): 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 = open(filename, 'w') f.write('hello, world?') f.close() os.utime(filename, (1368379500, 1368379500)) -- cgit v1.2.1