summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2011-11-17 01:46:57 -0600
committerMichael Merickel <michael@merickel.org>2011-11-17 01:46:57 -0600
commitd79d133699846b5bb90c1df7359af6624ca62e82 (patch)
treee4a49c0b5509ce0a0ee64c372dc6bbddfbb07b5e
parent43a189c078b4e0ad6851829ad26ce6589bf2088a (diff)
downloadpyramid-d79d133699846b5bb90c1df7359af6624ca62e82.tar.gz
pyramid-d79d133699846b5bb90c1df7359af6624ca62e82.tar.bz2
pyramid-d79d133699846b5bb90c1df7359af6624ca62e82.zip
Allow creating Configurator in an interpreter. Fixes #328.
-rw-r--r--pyramid/path.py2
-rw-r--r--pyramid/tests/test_path.py5
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):