From d79d133699846b5bb90c1df7359af6624ca62e82 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Thu, 17 Nov 2011 01:46:57 -0600 Subject: Allow creating Configurator in an interpreter. Fixes #328. --- pyramid/path.py | 2 +- pyramid/tests/test_path.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pyramid/path.py b/pyramid/path.py index 9c7be4c57..86c1c5857 100644 --- a/pyramid/path.py +++ b/pyramid/path.py @@ -25,7 +25,7 @@ def package_name(pkg_or_module): package name of the package in which the module lives. If this function is passed a package, return the dotted Python package name of the package itself.""" - if pkg_or_module is None: + if pkg_or_module is None or pkg_or_module.__name__ == '__main__': return '__main__' pkg_filename = pkg_or_module.__file__ pkg_name = pkg_or_module.__name__ diff --git a/pyramid/tests/test_path.py b/pyramid/tests/test_path.py index c2261d223..29b9baf1f 100644 --- a/pyramid/tests/test_path.py +++ b/pyramid/tests/test_path.py @@ -162,6 +162,11 @@ class TestPackageName(unittest.TestCase): def test_it_None(self): result = self._callFUT(None) self.assertEqual(result, '__main__') + + def test_it_main(self): + import __main__ + result = self._callFUT(__main__) + self.assertEqual(result, '__main__') class DummyPackageOrModule: def __init__(self, real_package_or_module, raise_exc=None): -- cgit v1.2.3