def test_caller_package(self): from pyramid_jinja2 import _PackageFinder pf = _PackageFinder() class MockInspect(object): def __init__(self, items=()): self.items = items def stack(self): return self.items pf.inspect = MockInspect() self.assertEqual(pf.caller_package(), None) import xml pf.inspect.items = [(Mock(f_globals={'__name__': 'xml'}),)]