예제 #1
0
 def test_cannot_add_qualifiers_without_runner_in_stack(self):
     rs = RunnerStack(None)
     with pytest.raises(err.VinoError) as exc_info:
         assert len(rs) == 0
         rs.add_qualifiers([0, 1])
     error = exc_info.value
     assert 'without specifying a processor' in str(error).lower()
예제 #2
0
 def test_cannot_add_qualifier_without_context(self, tags):
     processors = ((t, None) for t in tags)
     rs = RunnerStack(None)
     rs.add(*processors)
     with pytest.raises(err.VinoError) as exc_info:
         rs.add_qualifiers([0, 1])
     error = exc_info.value
     assert 'must be given a context' in str(error).lower()
예제 #3
0
 def test_can_add_qualifiers_if_context_has_QStack_class(self, tags):
     processors = ((t, None) for t in tags)
     c = ctx.Context()
     c = ctx.Context(qualifier_stack_cls=quals.ItemQualifierStack)
     rs = RunnerStack(c)
     rs.add(*processors)
     rs.add_qualifiers([0, 1])
     qstack = rs[-1]['qualifiers']
     qualifiers = qstack.qualifiers
     assert qualifiers['indices'] == {0, 1}
예제 #4
0
 def test_cannot_add_qualifier_if_context_has_no_QStack_class(self, tags):
     processors = ((t, None) for t in tags)
     c = ctx.Context(qualifier_stack_cls=quals.ItemQualifierStack)
     rs = RunnerStack(c)
     rs.add(*processors)
     c.qualifier_stack_cls = None
     with pytest.raises(err.VinoError) as exc_info:
         rs.add_qualifiers([0, 1])
     error = exc_info.value
     assert ('qualifierstack constructor must be specified'
             in str(error).lower())
예제 #5
0
 def test_cannot_add_qualifiers_if_runner_has_qualifiers_set_to_False(
         self, tags):
     processors = ((t, None) for t in tags)
     c = ctx.Context()
     c._qualifier_stack_constructor = quals.ItemQualifierStack
     rs = RunnerStack(c)
     rs.add(*processors)
     rs[-1]['qualifiers'] = False
     with pytest.raises(err.VinoError) as exc_info:
         rs.add_qualifiers([0, 1])
     error = exc_info.value
     assert 'does not accept qualifiers' in str(error).lower()
예제 #6
0
 def test_successive_qualifier_applications_merges_qualifiers(self, tags):
     processors = ((t, None) for t in tags)
     c = ctx.Context(qualifier_stack_cls=quals.ItemQualifierStack)
     rs = RunnerStack(c)
     rs.add(*processors)
     rs.add_qualifiers([0, 1])
     qstack = rs[-1]['qualifiers']
     qualifiers = qstack.qualifiers
     assert qualifiers['indices'] == {0, 1}
     rs.add_qualifiers([1, 3, 8])
     assert qualifiers['indices'] == {0, 1, 3, 8}
     rs.add_qualifiers(9, 5, 0, 1)
     assert qualifiers['indices'] == {0, 1, 3, 8, 9, 5}