Я новичок в pytest и пытаюсь использовать прибор.
У меня есть следующий код:
Я пытаюсь преобразовать следующую логику в приспособление:
У меня есть функция с именем "kubernetes_.fixture", которая является приспособлением
возвращает мне функциональное приспособление. а затем я делаю список из них и отправляю его в другую функцию.
Но, когда я меняю логику, чтобы объединить 2 логики в одной функции прибора
Я получаю следующую ошибку.
pod2 = (kubernetes_.fixture([samelink_pod2], namespace='namespace'))
pod3 = (kubernetes_.fixture([difflink_pod3], namespace='namespace'))
pod4 = (kubernetes_.fixture([diff_leaf_pod4], namespace='namespace'))
pod5 = (kubernetes_.fixture([diff_leaf_pod5], namespace='namespace'))
@pytest.fixture
def pod_list_fixture(pod2, pod3, pod4, pod5):
return [pod2, pod3, pod4, pod5]
def test_same_node_traffic(pod_list_fixture):
connected_ips = [pod.ip() for pod in pod_list_fixture]<<<< Never get ERRROR HERE
________________________________________________________________
@pytest.fixture
def pod_list_fixture():
fixlist = []
for pod in podlist:
fixture = (kubernetes_.fixture([pod], namespace='namespace'))
fixlist.append(fixture)
return fixlist
def test_same_node_traffic(pod_list_fixture):
connected_ips = [pod.ip() for pod in pod_list_fixture] <<< Get a Error here saying function object doesnt have attribute 'ip'
след вызовов TRACEBACK:
pod_list_fixture = [<function fixture.<locals>._fixture at 0x7f9678734268>, <function fixture.<locals>._fixture at 0x7f96787348c8>, <func...>, <function fixture.<locals>._fixture at 0x7f9678734840>, <function fixture.<locals>._fixture at 0x7f9678734d08>, ...]
def test_different_uplink(pod_list_fixture):
> connected_ips = [pod.ip() for pod in pod_list_fixture]
test_remote.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <list_iterator object at 0x7f965865c860>
> connected_ips = [pod.ip() for pod in pod_list_fixture]
E AttributeError: 'function' object has no attribute 'ip'
test_remote.py:58: AttributeError
__________________________ test_different_leaf[kubernetes-1.8] ___________________________
pod_list_fixture = [<function fixture.<locals>._fixture at 0x7f9678734268>, <function fixture.<locals>._fixture at 0x7f96787348c8>, <func...>, <function fixture.<locals>._fixture at 0x7f9678734840>, <function fixture.<locals>._fixture at 0x7f9678734d08>, ...]
def test_different_leaf(pod_list_fixture):
> connected_ips = [pod.ip() for pod in pod_list_fixture]
test_remote.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <list_iterator object at 0x7f9658649f60>
> connected_ips = [pod.ip() for pod in pod_list_fixture]
E AttributeError: 'function' object has no attribute 'ip'
test_remote.py:64: AttributeError