diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2016-02-03 10:20:29 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-02-03 10:20:29 -0500 |
| commit | 20413e816e9c0809c97598b0a758120be6460f90 (patch) | |
| tree | 3a316c32a382c77e0fc2b3cde784ac401675086b /pkg_resources/tests/test_resources.py | |
| parent | a9a38182f64da197bd52efdf3c63d68448c80942 (diff) | |
| download | python-setuptools-git-20413e816e9c0809c97598b0a758120be6460f90.tar.gz | |
Extract ns_str as class attribute
Diffstat (limited to 'pkg_resources/tests/test_resources.py')
| -rw-r--r-- | pkg_resources/tests/test_resources.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index 5b3ba546..e25fbc78 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -610,6 +610,8 @@ class TestParsing: class TestNamespaces: + ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" + @pytest.yield_fixture def symlinked_tmpdir(self, tmpdir): """ @@ -657,13 +659,12 @@ class TestNamespaces: tmpdir = symlinked_tmpdir sys.path.append(str(tmpdir / 'site-pkgs2')) site_dirs = tmpdir / 'site-pkgs', tmpdir / 'site-pkgs2' - ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" for site in site_dirs: pkg1 = site / 'pkg1' pkg2 = pkg1 / 'pkg2' pkg2.ensure_dir() - (pkg1 / '__init__.py').write_text(ns_str, encoding='utf-8') - (pkg2 / '__init__.py').write_text(ns_str, encoding='utf-8') + (pkg1 / '__init__.py').write_text(self.ns_str, encoding='utf-8') + (pkg2 / '__init__.py').write_text(self.ns_str, encoding='utf-8') import pkg1 assert "pkg1" in pkg_resources._namespace_packages # attempt to import pkg2 from site-pkgs2 @@ -695,7 +696,6 @@ class TestNamespaces: tmpdir / "site-pkgs3", ) - ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" vers_str = "__version__ = %r" for number, site in enumerate(site_dirs, 1): @@ -704,7 +704,7 @@ class TestNamespaces: nspkg = site / 'nspkg' subpkg = nspkg / 'subpkg' subpkg.ensure_dir() - (nspkg / '__init__.py').write_text(ns_str, encoding='utf-8') + (nspkg / '__init__.py').write_text(self.ns_str, encoding='utf-8') (subpkg / '__init__.py').write_text(vers_str % number, encoding='utf-8') import nspkg.subpkg |
