Merge pull request #54606 from garethgreenaway/2019_2_1_port_52698

[master] Porting #52698 to master
This commit is contained in:
Daniel Wozniak 2019-11-14 14:58:02 -07:00 committed by GitHub
commit f5b4b14c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,24 +244,24 @@ def pytest_runtest_setup(item):
'''
Fixtures injection based on markers or test skips based on CLI arguments
'''
destructive_tests_marker = item.get_marker('destructive_test')
destructive_tests_marker = item.get_closest_marker('destructive_test')
if destructive_tests_marker is not None:
if item.config.getoption('--run-destructive') is False:
pytest.skip('Destructive tests are disabled')
os.environ['DESTRUCTIVE_TESTS'] = six.text_type(item.config.getoption('--run-destructive'))
expensive_tests_marker = item.get_marker('expensive_test')
expensive_tests_marker = item.get_closest_marker('expensive_test')
if expensive_tests_marker is not None:
if item.config.getoption('--run-expensive') is False:
pytest.skip('Expensive tests are disabled')
os.environ['EXPENSIVE_TESTS'] = six.text_type(item.config.getoption('--run-expensive'))
skip_if_not_root_marker = item.get_marker('skip_if_not_root')
skip_if_not_root_marker = item.get_closest_marker('skip_if_not_root')
if skip_if_not_root_marker is not None:
if os.getuid() != 0:
pytest.skip('You must be logged in as root to run this test')
skip_if_binaries_missing_marker = item.get_marker('skip_if_binaries_missing')
skip_if_binaries_missing_marker = item.get_closest_marker('skip_if_binaries_missing')
if skip_if_binaries_missing_marker is not None:
binaries = skip_if_binaries_missing_marker.args
if len(binaries) == 1:
@ -286,7 +286,7 @@ def pytest_runtest_setup(item):
)
)
requires_network_marker = item.get_marker('requires_network')
requires_network_marker = item.get_closest_marker('requires_network')
if requires_network_marker is not None:
only_local_network = requires_network_marker.kwargs.get('only_local_network', False)
has_local_network = False