Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conftest rand_one_dut_hostname IndexError #14830

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ def rand_one_dut_hostname(request):
"""
"""
global rand_one_dut_hostname_var
if rand_one_dut_hostname_var is None:
set_rand_one_dut_hostname(request)
return rand_one_dut_hostname_var


Expand All @@ -442,6 +444,8 @@ def rand_selected_dut(duthosts, rand_one_dut_hostname):
@pytest.fixture(scope="module")
def selected_rand_dut(request):
global rand_one_dut_hostname_var
if rand_one_dut_hostname_var is None:
set_rand_one_dut_hostname(request)
return rand_one_dut_hostname_var


Expand Down Expand Up @@ -1544,12 +1548,6 @@ def pytest_generate_tests(metafunc): # noqa E302
if dut_fixture_name and "selected_dut" in metafunc.fixturenames:
metafunc.parametrize("selected_dut", duts_selected, scope="module", indirect=True)

# When rand_one_dut_hostname used and select a dut for test, initialize rand_one_dut_hostname_var
# rand_one_dut_hostname and rand_selected_dut will use this variable for setup test case
# selected_rand_dut will use this variable for setup TACACS
if "rand_one_dut_hostname" in metafunc.fixturenames:
set_rand_one_dut_hostname(metafunc)

if "enum_dut_portname" in metafunc.fixturenames:
metafunc.parametrize("enum_dut_portname", generate_port_lists(metafunc, "all_ports"))

Expand Down
Loading