error in zope.app.tree test
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zope.app.tree |
Fix Committed
|
Medium
|
Christian Theune |
Bug Description
One of the tests in test_node.py in the zope.app.tree.tests package is not functioning as intended (as far as I understand the test).
The test case reads:
1 def test_children(
2 # test hasChildren()
3 root_node = self.root_node
4 self.failUnless
5
6 # test getChildNodes()
7 children = [node.context for node in root_node.
8 expected = [self.items['b'], self.items['c']]
9 self.assertEqua
10
11 # test with filter
12 expand_all = self.items.keys() # expand all nodes
13 # emulate node expansion with the FilterByObject filter
14 filter = FilterByObject(
15 filtered_root = Node(self.root_obj, expand_all, filter)
16 children = [node.context for node in root_node.
17 expected = [self.items['b'], self.items['c']]
18 self.assertEqua
The problem is in the filter part. For one thing, the filtered_root object defined in line 15 is not used for the test in line 18, making the latter a simple duplication of the test in line 9.
Furthermore, since the filter is on the exanded_nodes list which is defined as [self.items['a'], self.items['c']] in the basetest module, the expected returned children would only be the self.items['c'] (see basetest.py in the same module).
Another problem is in the declaration of the Filter class - see below:
1 class FilterByObject(
2 """Simple filter that filters out any objects that wasn't passed
3 in as a valid object before
4 """
5 implements(
6
7 def __init__(self, *objects):
8 self.objects = objects
9
10 def match(self, obj):
11 return obj in self.objects
For one thing, the interface from zope.app.
Attached is a suggested patch for the above issues. I realize it may be quite crude and I would be happy for feedback as I'm all the way at the bottom of the learning curve.
Best regards,
Dragos.
affects: | zope3 → zope.app.tree |
That's definitely phishy. Looking at this.