[qmtest] Context handling bug?

Nathaniel Smith njs at codesourcery.com
Wed Jul 9 22:08:45 UTC 2003


On Wed, Jul 09, 2003 at 03:05:16PM +0400, Vladimir Prus wrote:
[Context.items() doesn't work right.]

Not too hard to fix; attached is a little patch that should make
things work right (it passes the test suite, but I haven't tested it
beyond that).  Let us know if it works for you...

(This patch leaves Context broken wrt other iteration interfaces, but
I'll get those later...)

-- Nathaniel

-- 
"Of course, the entire effort is to put oneself
 Outside the ordinary range
 Of what are called statistics."
  -- Stephan Spender
-------------- next part --------------
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=setup_path.py --exclude=qm.sh --exclude=qm.spec qm-clean/ChangeLog qm-context-items/ChangeLog
--- qm-clean/ChangeLog	2003-07-03 12:28:22.000000000 -0700
+++ qm-context-items/ChangeLog	2003-07-09 14:50:06.000000000 -0700
@@ -1,3 +1,7 @@
+2003-07-09  Nathaniel Smith  <njs at codesourcery.com>
+
+	* qm/test/context.py (Context.items): New method.
+
 2003-07-02  Nathaniel Smith  <njs at codesourcery.com>
 
 	* qm/test/base.py (load_results): Rename 'ResultSource' to
diff -urN --exclude='*~' --exclude='.*' --exclude=CVS --exclude='*.pyo' --exclude='*.pyc' --exclude=build --exclude=GNUmakefile --exclude=config.log --exclude=config.status --exclude=setup_path.py --exclude=qm.sh --exclude=qm.spec qm-clean/qm/test/context.py qm-context-items/qm/test/context.py
--- qm-clean/qm/test/context.py	2003-06-21 00:57:48.000000000 -0700
+++ qm-context-items/qm/test/context.py	2003-07-09 14:49:40.000000000 -0700
@@ -165,6 +165,20 @@
                 raise ContextException(key)
 
 
+    def items(self):
+
+        if self.__context is None:
+            return super(Context, self).items()
+        else:
+            # Have to be careful, because self.__context and self may
+            # contain different values for the same keys, and the values
+            # defined in self should override the values defined in
+            # self.__context.
+            unified_dict = dict(self.__context.items())
+            unified_dict.update(self)
+            return unified_dict.items()
+
+
     # Helper methods.
 
     def GetAddedProperties(self):


More information about the qmtest mailing list