[pypy-svn] r46581 - in pypy/dist/pypy/config: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Sep 14 14:54:58 CEST 2007


Author: cfbolz
Date: Fri Sep 14 14:54:56 2007
New Revision: 46581

Modified:
   pypy/dist/pypy/config/config.py
   pypy/dist/pypy/config/pypyoption.py
   pypy/dist/pypy/config/test/test_config.py
   pypy/dist/pypy/config/test/test_pypyoption.py
Log:
better suggestion handling


Modified: pypy/dist/pypy/config/config.py
==============================================================================
--- pypy/dist/pypy/config/config.py	(original)
+++ pypy/dist/pypy/config/config.py	Fri Sep 14 14:54:56 2007
@@ -267,12 +267,18 @@
             for path, reqvalue in self._requires:
                 toplevel = config._cfgimpl_get_toplevel()
                 homeconfig, name = toplevel._cfgimpl_get_home_by_path(path)
-                homeconfig.setoption(name, reqvalue, who)
+                homeconfig.setoption(name, reqvalue, "required")
         if value and self._suggests is not None:
             for path, reqvalue in self._suggests:
                 toplevel = config._cfgimpl_get_toplevel()
                 homeconfig, name = toplevel._cfgimpl_get_home_by_path(path)
-                homeconfig.setoption(name, reqvalue, "suggested")
+                try:
+                    homeconfig.setoption(name, reqvalue, "suggested")
+                except ValueError:
+                    # setting didn't work, but that is fine, since it is
+                    # suggested
+                    pass
+
         super(BoolOption, self).setoption(config, value, who)
 
     def add_optparse_option(self, argnames, parser, config):

Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py	(original)
+++ pypy/dist/pypy/config/pypyoption.py	Fri Sep 14 14:54:56 2007
@@ -196,12 +196,12 @@
                    default=False,
                    requires=[("objspace.std.withmultidict", True),
                              ("objspace.std.withtypeversion", True),
-                             ("translation.rweakref", False)]),
+                             ("translation.rweakref", True)]),
         BoolOption("withmethodcache",
                    "try to cache method lookups",
                    default=False,
                    requires=[("objspace.std.withtypeversion", True),
-                             ("translation.rweakref", False)]),
+                             ("translation.rweakref", True)]),
         BoolOption("withmethodcachecounter",
                    "try to cache methods and provide a counter in __pypy__. "
                    "for testing purposes only.",

Modified: pypy/dist/pypy/config/test/test_config.py
==============================================================================
--- pypy/dist/pypy/config/test/test_config.py	(original)
+++ pypy/dist/pypy/config/test/test_config.py	Fri Sep 14 14:54:56 2007
@@ -471,6 +471,41 @@
     assert c.opt
     assert not c.toplevel
 
+def test_suggests_can_fail():
+    descr = OptionDescription("test", '', [
+        BoolOption("t1", "", default=False),
+        BoolOption("t2", "", default=False,
+                   requires=[("t3", True)]),
+        BoolOption("t3", "", default=False),
+        BoolOption("opt", "", default=False,
+                   suggests=[("t1", True), ("t2", True)])
+    ])
+    c = Config(descr)
+    assert not c.t1
+    assert not c.t2
+    assert not c.t3
+    assert not c.opt
+    c.opt = True
+    assert c.opt
+    assert c.t1
+    assert c.t2
+    assert c.t3
+    # does not crash
+    c.t2 = False
+    assert not c.t2
+
+    c = Config(descr)
+    c.t3 = False
+    assert not c.t3
+    # does not crash
+    c.opt = True
+    assert c.opt
+    assert not c.t3
+    assert not c.t2
+
+
+
+
 def test_delattr():
     descr = OptionDescription("opt", "", [
     OptionDescription("s1", "", [

Modified: pypy/dist/pypy/config/test/test_pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/test/test_pypyoption.py	(original)
+++ pypy/dist/pypy/config/test/test_pypyoption.py	Fri Sep 14 14:54:56 2007
@@ -33,7 +33,6 @@
             assert configdocdir.join(fn).check()
 
 def test_rweakref_required():
-    py.test.skip('fixme!')
     conf = get_pypy_config()
     conf.translation.rweakref = False
     conf.objspace.std.allopts = True



More information about the Pypy-commit mailing list