[Zope-Checkins] CVS: Releases/Zope/lib/python/Products/PythonScripts/tests - testPythonScript.py:1.16

Evan Simpson evan at 4-am.com
Mon Mar 8 12:08:37 EST 2004


Update of /cvs-repository/Releases/Zope/lib/python/Products/PythonScripts/tests
In directory cvs.zope.org:/tmp/cvs-serv1133/lib/python/Products/PythonScripts/tests

Modified Files:
	testPythonScript.py 
Log Message:
Script (Python) objects now have a _filepath attribute, also used as the '__file__' global at runtime.  This prevents an import problem caused by the fix to #1074.


=== Releases/Zope/lib/python/Products/PythonScripts/tests/testPythonScript.py 1.15 => 1.16 ===
--- Releases/Zope/lib/python/Products/PythonScripts/tests/testPythonScript.py:1.15	Thu Jan 15 18:09:08 2004
+++ Releases/Zope/lib/python/Products/PythonScripts/tests/testPythonScript.py	Mon Mar  8 12:08:06 2004
@@ -10,7 +10,7 @@
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-import os, unittest
+import os, unittest, warnings
 
 from Products.PythonScripts.PythonScript import PythonScript
 from AccessControl.SecurityManagement import newSecurityManager
@@ -55,19 +55,16 @@
         return ps
 
     def _filePS(self, fname, bind=None):
-        ps = PythonScript(fname)
+        ps = VerifiedPythonScript(fname)
         ps.ZBindings_edit(bind or {})
         ps.write(readf(fname))
         ps._makeFunction()
+        if ps.errors:
+            raise SyntaxError, ps.errors[0]
         return ps
 
-
 class TestPythonScriptNoAq(PythonScriptTestBase):
 
-    def fail(self):
-        'Fail if called'
-        assert 0, 'Fail called'
-
     def testEmpty(self):
         empty = self._newPS('')()
         self.failUnless(empty is None)
@@ -238,9 +235,12 @@
         self.assertEqual(results, 8)
 
     def test__name__(self):
-        fname = 'class.__name__'
-        f = self._filePS(fname)
+        f = self._filePS('class.__name__')
         self.assertEqual(f(), ('?.foo', "'string'"))
+
+    def test_filepath(self):
+        f = self._filePS('filepath')
+        self.assertEqual(f(), [0])
 
 def test_suite():
     suite = unittest.TestSuite()




More information about the Zope-Checkins mailing list