From 6c95122777c8449056115292b492ec3e1e0d6e50 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Fri, 16 Dec 2022 04:56:02 +0100 Subject: Fix functional tests and docs generation First, fix test_help(). A commit[1], which first appeared in Python 3.10, changes the output of the help feature of argparse. Options used to be in a section named "Optional arguments:", and they are now in a section named "Options:". Second, tox 4 changes the behaviour of tox, and {toxinidir}/requirements.txt is no longer installed automagically in the docs virtual environment. This causes autodoc to fail on some imports. We explicitely add {toxinidir}/requirements.txt to the list of dependencies to fix this issue. These issues should be fixed in separate patches, but since they both block the CI, they depend on each other. [1] https://github.com/python/cpython/pull/23858 Change-Id: Ia7866390b31f469bdea95624325a13aaf45a496e Closes-Bug: #2002566 --- glanceclient/tests/functional/v1/test_readonly_glance.py | 9 ++++++++- glanceclient/tests/functional/v2/test_readonly_glance.py | 9 ++++++++- tox.ini | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/glanceclient/tests/functional/v1/test_readonly_glance.py b/glanceclient/tests/functional/v1/test_readonly_glance.py index a7024aa..ffd8358 100644 --- a/glanceclient/tests/functional/v1/test_readonly_glance.py +++ b/glanceclient/tests/functional/v1/test_readonly_glance.py @@ -51,7 +51,14 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase): commands = [] cmds_start = lines.index('Positional arguments:') - cmds_end = lines.index('Optional arguments:') + try: + # Starting in Python 3.10, argparse displays options in the + # "Options:" section... + cmds_end = lines.index('Options:') + except ValueError: + # ... but before Python 3.10, options were displayed in the + # "Optional arguments:" section. + cmds_end = lines.index('Optional arguments:') command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)') for line in lines[cmds_start:cmds_end]: match = command_pattern.match(line) diff --git a/glanceclient/tests/functional/v2/test_readonly_glance.py b/glanceclient/tests/functional/v2/test_readonly_glance.py index 4d7f92d..7bc86d1 100644 --- a/glanceclient/tests/functional/v2/test_readonly_glance.py +++ b/glanceclient/tests/functional/v2/test_readonly_glance.py @@ -71,7 +71,14 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase): commands = [] cmds_start = lines.index('Positional arguments:') - cmds_end = lines.index('Optional arguments:') + try: + # Starting in Python 3.10, argparse displays options in the + # "Options:" section... + cmds_end = lines.index('Options:') + except ValueError: + # ... but before Python 3.10, options were displayed in the + # "Optional arguments:" section. + cmds_end = lines.index('Optional arguments:') command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)') for line in lines[cmds_start:cmds_end]: match = command_pattern.match(line) diff --git a/tox.ini b/tox.ini index 981ea8f..f516070 100644 --- a/tox.ini +++ b/tox.ini @@ -54,7 +54,9 @@ commands = [testenv:docs] basepython = python3 -deps = -r{toxinidir}/doc/requirements.txt +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/doc/requirements.txt commands = sphinx-build -W -b html doc/source doc/build/html sphinx-build -W -b man doc/source doc/build/man -- cgit v1.2.1