'Test nested namespace packages
Create namespace packages in the following tree :
site-packages-1/pkg1/pkg2
site-packages-2/pkg1/pkg2
Check both are in the _namespace_packages dict and that their __path__
is correct'

def test_two_levels_deep(self):

    sys.path.append(os.path.join(self._tmpdir, 'site-pkgs2'))
    os.makedirs(os.path.join(self._tmpdir, 'site-pkgs', 'pkg1', 'pkg2'))
    os.makedirs(os.path.join(self._tmpdir, 'site-pkgs2', 'pkg1', 'pkg2'))
    ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n"
    for site in ['site-pkgs', 'site-pkgs2']:
        pkg1_init = open(os.path.join(self._tmpdir, site, 'pkg1', '__init__.py'), 'w')
        pkg1_init.write(ns_str)
        pkg1_init.close()
        pkg2_init = open(os.path.join(self._tmpdir, site, 'pkg1', 'pkg2', '__init__.py'), 'w')
        pkg2_init.write(ns_str)
        pkg2_init.close()
    import pkg1
    self._assertIn('pkg1', pkg_resources._namespace_packages.keys())
    try:
        import pkg1.pkg2
    except ImportError:
        self.fail('Setuptools    tried    to    import    the    parent    namespace    package')
    self._assertIn('pkg1.pkg2', pkg_resources._namespace_packages.keys())
    self.assertEqual(pkg_resources._namespace_packages['pkg1'], ['pkg1.pkg2'])
    self.assertEqual(pkg1.pkg2.__path__, [os.path.join(self._tmpdir, 'site-pkgs', 'pkg1', 'pkg2'), os.path.join(self._tmpdir, 'site-pkgs2', 'pkg1', 'pkg2')])
