[Zope-Checkins] CVS: Zope/lib/python/RestrictedPython/tests - testRestrictions.py:1.13

Shane Hathaway shane@cvs.zope.org
Wed, 12 Jun 2002 16:39:50 -0400


Update of /cvs-repository/Zope/lib/python/RestrictedPython/tests
In directory cvs.zope.org:/tmp/cvs-serv5054/lib/python/RestrictedPython/tests

Modified Files:
	testRestrictions.py 
Log Message:
It's really not safe for unit test modules to change sys.path.  Doing
so makes the full suite brittle.  Cleaned out all the places where unit
tests change sys.path.  (Use the PYTHONPATH environment variable instead.)

Also brought SearchIndex tests up to date, which I didn't really need to do
since SearchIndex is deprecated, but I did it as part of figuring out the
failed Interface tests, so I might as well check in my work. ;-)  One of the
test modules in SearchIndex forgets to define a global named "Dummy",
actually, so all the tests were failing before this checkin anyway.


=== Zope/lib/python/RestrictedPython/tests/testRestrictions.py 1.12 => 1.13 ===
 import sys, os
 
-if __name__=='__main__':
-    sys.path.append(os.path.join(os.pardir, os.pardir))
-
 import unittest
 from RestrictedPython import compile_restricted, PrintCollector
 from RestrictedPython.Eval import RestrictionCapableEval
@@ -12,12 +9,11 @@
 from types import FunctionType
 
 if __name__=='__main__':
-    sys.path.append(os.path.join(os.pardir, os.pardir))
-    here = os.curdir
+    here = os.getcwd()
 else:
-    from App.Common import package_home
-    from RestrictedPython import tests
-    here = package_home(tests.__dict__)
+    here = os.path.dirname(__file__)
+    if not here:
+        here = os.getcwd()
 
 def _getindent(line):
     """Returns the indentation level of the given line."""