summaryrefslogtreecommitdiff
path: root/taskflow/test.py
diff options
context:
space:
mode:
authorIvan A. Melnikov <imelnikov@griddynamics.com>2014-01-23 20:09:43 +0400
committerIvan A. Melnikov <imelnikov@griddynamics.com>2014-01-30 23:26:52 +0400
commit7ff1cde77e97fae6fde61ca515cbbce98b0d3b92 (patch)
tree78effd537655de600f1b37c41b5931eb231a3284 /taskflow/test.py
parentc6bc654180cce74eaec19db3d8e3ed5693013b2a (diff)
downloadtaskflow-7ff1cde77e97fae6fde61ca515cbbce98b0d3b92.tar.gz
Engine tests refactoring
This change makes tests from test_action_engine.py more focused and deterministic: - replace assertIsSubset with assertIsSuperAndSubsequence, which checks order, too; - remove all sleeping from test tasks, it does not help anything anyway; - refactor tests that verify behaviour in case of task failing in nested subflow. Change-Id: I87ce1e5eed4a3a93c3c6593b618e82cfdd68204f
Diffstat (limited to 'taskflow/test.py')
-rw-r--r--taskflow/test.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/taskflow/test.py b/taskflow/test.py
index 68c6942..1da10aa 100644
--- a/taskflow/test.py
+++ b/taskflow/test.py
@@ -72,15 +72,19 @@ class TestCase(testcase.TestCase):
matcher = matchers.MatchesRegex(pattern)
self.assertThat(text, matcher)
- def assertIsSubset(self, super_set, sub_set, msg=None):
- missing_set = set()
- for e in sub_set:
- if e not in super_set:
- missing_set.add(e)
- if len(missing_set):
- if msg is not None:
+ def assertIsSuperAndSubsequence(self, super_seq, sub_seq, msg=None):
+ super_seq = list(super_seq)
+ sub_seq = list(sub_seq)
+ current_tail = super_seq
+ for sub_elem in sub_seq:
+ try:
+ super_index = current_tail.index(sub_elem)
+ except ValueError:
+ # element not found
+ if msg is None:
+ msg = ("%r is not subsequence of %r: "
+ "element %r not found in tail %r"
+ % (sub_seq, super_seq, sub_elem, current_tail))
self.fail(msg)
else:
- self.fail("Subset %s has %s elements which are not in the "
- "superset %s." % (sub_set, list(missing_set),
- list(super_set)))
+ current_tail = current_tail[super_index + 1:]