-
Notifications
You must be signed in to change notification settings - Fork 40
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
Some tests fail when py.test has a different name #121
Comments
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 |
@qha works for me |
Thank you for the confirmation! |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: