diff options
| -rw-r--r-- | pyramid/path.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_path.py | 5 |
2 files changed, 6 insertions, 1 deletions
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): |
