Open lgbaldoni opened 4 years ago
OK, so this is rather awful hack how to deal with the problem:
--- a/test/test_parser.py
+++ b/test/test_parser.py
@@ -1,4 +1,8 @@
import argparse
+import os
+import sys
+print("sys.path = {}".format(sys.path))
+
from sphinxarg.parser import parse_parser, parser_navigate
@@ -129,6 +133,8 @@ def test_parse_description():
def test_parse_nested():
+ pytest_name = os.environ['PYTEST_NAME'] if 'PYTEST_NAME' in os.environ \
+ else 'py.test'
parser = argparse.ArgumentParser()
parser.add_argument('foo', default=False, help='foo help')
parser.add_argument('bar', default=False)
@@ -157,8 +163,8 @@ def test_parse_nested():
{
'name': 'install',
'help': 'install help',
- 'usage': 'usage: py.test install [-h] [--upgrade] ref',
- 'bare_usage': 'py.test install [-h] [--upgrade] ref',
+ 'usage': 'usage: {} install [-h] [--upgrade] ref'.format(pytest_name),
+ 'bare_usage': '{} install [-h] [--upgrade] ref'.format(pytest_name),
'action_groups': [
{
'title': 'Positional Arguments',
@@ -188,6 +194,8 @@ def test_parse_nested():
def test_parse_nested_traversal():
+ pytest_name = os.environ['PYTEST_NAME'] if 'PYTEST_NAME' in os.environ \
+ else 'py.test'
parser = argparse.ArgumentParser()
subparsers1 = parser.add_subparsers()
@@ -223,8 +231,8 @@ def test_parse_nested_traversal():
{
'name': 'level3',
'help': '',
- 'usage': 'usage: py.test level1 level2 level3 [-h] foo bar',
- 'bare_usage': 'py.test level1 level2 level3 [-h] foo bar',
+ 'usage': 'usage: {} level1 level2 level3 [-h] foo bar'.format(pytest_name),
+ 'bare_usage': '{} level1 level2 level3 [-h] foo bar'.format(pytest_name),
'action_groups': [
{
'title': 'Positional Arguments',
(and of course you have set environmental variable PYTEST_NAME
).
I made a less awful fix in d7a8384f1d4a0a3074a803fc6429481a918e4780 (part of #113), could you test it and see if it solves the problem for you too?
@qha works for me
Thank you for the confirmation!
Trying to package sphinx-argparse for openSUSE Tumbleweed and I've stumbled into a small problem.
To invoke the test we use a macro that cycles through the various python incarnations (2, 3 and pypy) and consequently each py.test executable comes with a different suffix. Unfortunately it looks like that test/test_parser.py has a hardcoded py.test name and takes exception to things being otherwise.
Do you see a way around this?
Regards