[Zope-CVS] CVS: Products/Basket/tests - testBasket.py:1.38

Chris McDonough chrism at plope.com
Sun Nov 27 15:32:36 EST 2005


Update of /cvs-repository/Products/Basket/tests
In directory cvs.zope.org:/tmp/cvs-serv15605/tests

Modified Files:
	testBasket.py 
Log Message:
remove_distribution_from_working_set failed to clean up namespace package __path__ entries inserted as a side effect of get_distribution().


=== Products/Basket/tests/testBasket.py 1.37 => 1.38 ===
--- Products/Basket/tests/testBasket.py:1.37	Sun Nov 27 14:51:55 2005
+++ Products/Basket/tests/testBasket.py	Sun Nov 27 15:32:36 2005
@@ -562,7 +562,11 @@
 
         self.failIf(sys.modules.has_key('Products.fiveproduct'))
 
-        result = basket.initialize(DummyProductContext('Basket'))
+        productcontext = DummyProductContext('Basket')
+
+        basket.preinitialize()
+
+        result = basket.initialize(productcontext)
 
         import Products.fiveproduct
 
@@ -608,6 +612,46 @@
             # clean up
             PlacelessSetup.tearDown(self)
 
+
+    def test_remove_product_distribution_from_working_set_fixes_ns_pkgs(self):
+        basket = self._makeOne()
+
+        # we use fiveproduct because it has a namespace package and is non
+        # zip-safe.  
+
+        basket.pdist_fname = os.path.join(self.fixtures,'pdist-fiveproduct.txt')
+        
+        sys.path.append(self.fixtures)
+        self.working_set.add_entry(self.fixtures)
+
+        self.failIf(sys.modules.has_key('Products.fiveproduct'))
+
+        productcontext = DummyProductContext('Basket')
+
+        basket.preinitialize()
+
+        result = basket.initialize(productcontext)
+
+        import Products.fiveproduct
+
+        self.failUnless(sys.modules.has_key('Products.fiveproduct'))
+
+        import Products
+
+        wrongpath = os.path.join(self.fixtures, 'fiveproduct-0.1-py2.3.egg',
+                                 'Products')
+        # this should have been removed during remove_product_d_f_w_s
+        self.failIf(wrongpath in Products.__path__)
+
+        # and should have been replaced with a tempfile path
+        ok = False
+        for path in Products.__path__:
+            if path.find('fiveproduct') > -1:
+                if path.endswith('Products'):
+                    ok = True
+
+        self.assertEqual(ok, True)
+        
     def _importProduct(self, name):
         __import__(name)
 



More information about the Zope-CVS mailing list