[pypy-svn] r33382 - in pypy/branch/even-more-config3/pypy/config: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Oct 17 18:07:20 CEST 2006


Author: cfbolz
Date: Tue Oct 17 18:07:19 2006
New Revision: 33382

Modified:
   pypy/branch/even-more-config3/pypy/config/config.py
   pypy/branch/even-more-config3/pypy/config/test/test_config.py
Log:
(pedronis, cfbolz): make sure that a later override of an option already set
does not change the option.


Modified: pypy/branch/even-more-config3/pypy/config/config.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/config/config.py	(original)
+++ pypy/branch/even-more-config3/pypy/config/config.py	Tue Oct 17 18:07:19 2006
@@ -55,6 +55,8 @@
         oldowner = self._cfgimpl_value_owners[child._name]
         oldvalue = getattr(self, name)
         if oldvalue != value and oldowner != "default":
+            if who == "default":
+                return
             raise ValueError('can not override value %s for option %s' %
                                 (value, name))
         child.setoption(self, value, who)

Modified: pypy/branch/even-more-config3/pypy/config/test/test_config.py
==============================================================================
--- pypy/branch/even-more-config3/pypy/config/test/test_config.py	(original)
+++ pypy/branch/even-more-config3/pypy/config/test/test_config.py	Tue Oct 17 18:07:19 2006
@@ -324,6 +324,14 @@
     assert config.backend == 'cli'
     assert config.type_system == 'oo'
     
+def test_overrides_dont_change_user_options():
+    descr = OptionDescription("test", "", [
+        BoolOption("b", "", default=False)])
+    config = Config(descr)
+    config.b = True
+    config.override({'b': False})
+    assert config.b
+    
 def test_str():
     descr = make_description()
     c = Config(descr)



More information about the Pypy-commit mailing list