Menu

#1 Harden workitem against programmer error

open
nobody
None
5
2002-03-11
2002-03-11
Tres Seaver
No

In reviewing the 'workitem' class, I inadvertently
broke an instance by making a couple of unexpected
calls:

- I called 'addTo' with a single ID (a string);
this didn't blow up, but didn't behave as desired,
either.

- I called 'unblock' one too many times.

Here is a patch:

--- workitem.py 4 Jan 2002 11:41:02 -0000 1.7
+++ workitem.py 11 Mar 2002 20:45:14 -0000
@@ -26,6 +26,8 @@

def addTo(self, id_list):
+ if type( id_list ) == type( '' ):
+ id_list = [ id_list ]
self._workitems_to.extend(id_list)
self._p_changed=1

@@ -58,6 +60,8 @@

def unblock(self, value=1):
self._blocked = self._blocked - value
+ if self._blocked < 0:
+ self._blocked = 0

def changeStatus(self, status):

Attached are unittests which exercises both bugs.

Discussion

  • Tres Seaver

    Tres Seaver - 2002-03-11

    unittest

     
  • Tres Seaver

    Tres Seaver - 2002-03-11

    Patch file

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.