wireshark/test/conftest.py
Gerald Combs 30c392f166 Tools+test: Call python3 explicitly.
PEP 394[1] says,

"In cases where the script is expected to be executed outside virtual
 environments, developers will need to be aware of the following
 discrepancies across platforms and installation methods:

  * Older Linux distributions will provide a python command that refers
    to Python 2, and will likely not provide a python2 command.

  * Some newer Linux distributions will provide a python command that
    refers to Python 3.

  * Some Linux distributions will not provide a python command at all by
    default, but will provide a python3 command by default."

Debian has forced the issue by choosing the third option[2]:

"NOTE: Debian testing (bullseye) has removed the "python" package and
 the '/usr/bin/python' symlink due to the deprecation of Python 2."

Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env
python3" in some places. Remove some 2/3 version checks if we know we're
running under Python 3. Remove the "coding: utf-8" in a bunch of places
since that's the default in Python 3.

[1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers
[2]https://wiki.debian.org/Python
2020-11-05 06:46:35 +00:00

46 lines
1.4 KiB
Python

#
# Wireshark tests
#
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
'''pytest configuration'''
import re
import fixtures
def pytest_addoption(parser):
parser.addoption('--disable-capture', action='store_true',
help='Disable capture tests'
)
parser.addoption('--program-path', help='Path to Wireshark executables.')
parser.addoption('--skip-missing-programs',
help='Skip tests that lack programs from this list instead of failing'
' them. Use "all" to ignore all missing programs.')
_all_test_groups = None
# this is set only to please case_unittests.test_unit_ctest_coverage
def pytest_collection_modifyitems(items):
'''Find all test groups.'''
global _all_test_groups
suites = []
for item in items:
name = item.nodeid.split("::")[0].replace(".py", "")
# When executed from the rootdir (e.g. "pytest test"), be sure to strip
# all preceding components ("test/suite_io" -> "suite_io").
name = re.sub(r'^.*/suite_', 'suite_', name)
name = name.replace("/", ".")
if name not in suites:
suites.append(name)
_all_test_groups = sorted(suites)
# Must enable pytest before importing fixtures_ws.
fixtures.enable_pytest()
from fixtures_ws import *
@fixtures.fixture(scope='session')
def all_test_groups():
return _all_test_groups