예제 #1
0
    def test_is_not_found(self):
        arg = namedtuple("Param", "a b c")
        with pytest.raises(AttributeError):
            helpers.get_attribute_from_argvalue(arg(1, 2, 3), "d")

        arg = ('a', 'b', 'c')
        with pytest.raises(IndexError):
            helpers.get_attribute_from_argvalue(arg, 4)
예제 #2
0
 def test_is_not_found_with_decorator(self):
     m = helpers.MarkDecorator("sanity")
     with pytest.raises(IndexError):
         helpers.get_attribute_from_argvalue(m, "a")
예제 #3
0
 def test_unnamedtuple(self):
     arg = ('a', 'b', 'c')
     attr = helpers.get_attribute_from_argvalue(arg, 1)
     assert attr == 'b'
예제 #4
0
 def test_is_namedtuple(self):
     arg = namedtuple("Param", "a b c")
     attr = helpers.get_attribute_from_argvalue(arg(1, 2, 3), "a")
     assert attr == 1
예제 #5
0
 def test_unnamedtuple_is_decorator(self):
     arg = ('a', 'b', 'c')
     m = helpers.MarkDecorator("sanity", [arg])
     attr = helpers.get_attribute_from_argvalue(m, 1)
     assert attr == 'b'
예제 #6
0
 def test_namedtuple_is_decorator(self):
     arg = namedtuple("Param", "a b c")
     m = helpers.MarkDecorator("sanity", [arg(1, 2, 3)])
     attr = helpers.get_attribute_from_argvalue(m, "a")
     assert attr == 1