[pypy-svn] r11963 - pypy/dist/lib-python

hpk at codespeak.net hpk at codespeak.net
Thu May 5 13:48:47 CEST 2005


Author: hpk
Date: Thu May  5 13:48:47 2005
New Revision: 11963

Modified:
   pypy/dist/lib-python/conftest.py
Log:
fix oldstyle and uselibfile handling.  The commandline
options '--oldstyle' and '--file' were not really having
the expected effect. They have now.  thanks Seo for 
pointing the problem out! 



Modified: pypy/dist/lib-python/conftest.py
==============================================================================
--- pypy/dist/lib-python/conftest.py	(original)
+++ pypy/dist/lib-python/conftest.py	Thu May  5 13:48:47 2005
@@ -278,11 +278,22 @@
         self.basename = basename 
         self.enabled = enabled 
         self.dumbtest = dumbtest 
-        if pypy_option.oldstyle: 
-            oldstyle = True 
-        self.oldstyle = oldstyle 
+        # we have to determine oldstyle and uselibfile values
+        # lazily because at RegrTest() call time the command
+        # line options haven't been parsed!
+        self._oldstyle = oldstyle 
+        self._uselibfile = uselibfile
         self.core = core
-        self.uselibfile = uselibfile
+
+    def oldstyle(self): 
+        return self._oldstyle or pypy_option.oldstyle 
+    oldstyle = property(oldstyle)
+
+    def uselibfile(self): 
+        return self._uselibfile or pypy_option.uselibfile 
+    uselibfile = property(uselibfile)
+
+        
 
     def getoptions(self): 
         l = []
@@ -321,9 +332,9 @@
         self._prepare(space)
         fspath = self.getfspath()
         assert fspath.check()
-        if self.oldstyle or pypy_option.oldstyle: 
+        if self.oldstyle: 
             space.enable_old_style_classes_as_default_metaclass() 
-        if self.uselibfile or pypy_option.uselibfile:
+        if self.uselibfile: 
             w_original_faked_file = space.appexec([], '''():
                 from _file import file
                 prev = __builtins__.file
@@ -333,9 +344,8 @@
         try: 
             callex(space, run_file, str(fspath), space)
         finally: 
-            if not pypy_option.oldstyle: 
-                space.enable_new_style_classes_as_default_metaclass() 
-            if self.uselibfile and not pypy_option.uselibfile:
+            space.enable_new_style_classes_as_default_metaclass() 
+            if self.uselibfile: 
                 space.appexec([w_original_faked_file], '''(prev):
                     __builtins__.file = __builtins__.open = prev
                 ''')
@@ -803,9 +813,9 @@
         alarm_script = pypydir.join('tool', 'alarm.py')
         regr_script = pypydir.join('tool', 'pytest', 'regrverbose.py')
         pypy_options = []
-        if regrtest.oldstyle or pypy_option.oldstyle: 
+        if regrtest.oldstyle: 
             pypy_options.append('--oldstyle') 
-        if regrtest.uselibfile or pypy_option.uselibfile: 
+        if regrtest.uselibfile: 
             pypy_options.append('--file') 
         sopt = " ".join(pypy_options) 
 



More information about the Pypy-commit mailing list