Skip to content

Commit

Permalink
test.py: grouped tests into 1 suit, i3.py: trivial one-line change
Browse files Browse the repository at this point in the history
3 test cases are grouped into one single test suit for easier
reading of test output. One test may not pass with the current
version of i3 window manager; explanation is added.

The one-line change in i3.py is just 'list.extend' to 'list +='
in i3.filter function for increased readability.
  • Loading branch information
ziberna committed Jun 10, 2012
1 parent c6aad6b commit d76a19d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion i3.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def filter(tree=None, function=None, **conditions):
matches = []
if 'nodes' in tree:
for node in tree['nodes']:
matches.extend(filter(node, function, **conditions))
matches += filter(node, function, **conditions)
return matches


Expand Down
12 changes: 7 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_event_type_error(self):
self.assertRaises(i3.EventTypeError, i3.parse_event_type, str(val))

def test_msg_error(self):
"""If i3.yada doesn't pass, see http://bugs.i3wm.org/report/ticket/693"""
self.assertRaises(i3.MessageError, i3.focus) # missing argument
self.assertRaises(i3.MessageError, i3.yada) # doesn't exist
self.assertRaises(i3.MessageError, i3.meh, 'some', 'args')
Expand Down Expand Up @@ -117,15 +118,16 @@ def test_filter2(self):
self.assertGreater(parent_count, 0)

def test_filter_function_wikipedia(self):
"""You have to have Wikipedia tab opened in a browser."""
import re
func = lambda node: re.search(r'Wikipedia', node['name'])
"""You have to have a Wikipedia tab opened in a browser."""
func = lambda node: 'Wikipedia' in node['name']
nodes = i3.filter(function=func)
self.assertTrue(nodes != [])
for node in nodes:
self.assertTrue('free encyclopedia' in node['name'])

if __name__ == '__main__':
test_suits = []
for Test in [ParseTest, SocketTest, GeneralTest]:
suite = unittest.TestLoader().loadTestsFromTestCase(Test)
unittest.TextTestRunner(verbosity=2).run(suite)
test_suits.append(unittest.TestLoader().loadTestsFromTestCase(Test))
unittest.TextTestRunner(verbosity=2).run(unittest.TestSuite(test_suits))

0 comments on commit d76a19d

Please sign in to comment.