mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Check if running in pytest instead of ignoring a specific argument
This commit is contained in:
parent
569ff8b58d
commit
580da11949
@ -88,8 +88,6 @@ development options:
|
|||||||
outdated errors
|
outdated errors
|
||||||
--restart-on-changes Restart the app when the source code is changed
|
--restart-on-changes Restart the app when the source code is changed
|
||||||
--recode-samples Open and save each file in samples/, for testing
|
--recode-samples Open and save each file in samples/, for testing
|
||||||
--snapshot-update KLUDGE: IGNORE THIS ARGUMENT INTENDED FOR pytest-
|
|
||||||
textual-snapshot
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Keyboard Shortcuts
|
### Keyboard Shortcuts
|
||||||
|
@ -3,9 +3,12 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
from textual_paint.__init__ import DEVELOPMENT, __version__
|
from textual_paint.__init__ import DEVELOPMENT, __version__
|
||||||
|
|
||||||
|
PYTEST = "pytest" in sys.modules
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Paint in the terminal.', usage='%(prog)s [options] [filename]', prog="textual-paint")
|
parser = argparse.ArgumentParser(description='Paint in the terminal.', usage='%(prog)s [options] [filename]', prog="textual-paint")
|
||||||
parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}')
|
parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}')
|
||||||
parser.add_argument('--theme', default='light', help='Theme to use, either "light" or "dark"', choices=['light', 'dark'])
|
parser.add_argument('--theme', default='light', help='Theme to use, either "light" or "dark"', choices=['light', 'dark'])
|
||||||
@ -25,8 +28,6 @@ dev_options.add_argument('--inspect-layout', action='store_true', help='Enables
|
|||||||
dev_options.add_argument('--clear-screen', action='store_true', help='Clear the screen before starting, to avoid seeing outdated errors')
|
dev_options.add_argument('--clear-screen', action='store_true', help='Clear the screen before starting, to avoid seeing outdated errors')
|
||||||
dev_options.add_argument('--restart-on-changes', action='store_true', help='Restart the app when the source code is changed')
|
dev_options.add_argument('--restart-on-changes', action='store_true', help='Restart the app when the source code is changed')
|
||||||
dev_options.add_argument('--recode-samples', action='store_true', help='Open and save each file in samples/, for testing')
|
dev_options.add_argument('--recode-samples', action='store_true', help='Open and save each file in samples/, for testing')
|
||||||
# TODO: don't parse arguments when running tests!
|
|
||||||
dev_options.add_argument('--snapshot-update', action='store_true', help='KLUDGE: IGNORE THIS ARGUMENT INTENDED FOR pytest-textual-snapshot')
|
|
||||||
|
|
||||||
parser.add_argument('filename', nargs='?', default=None, help='Path to a file to open. File will be created if it doesn\'t exist.')
|
parser.add_argument('filename', nargs='?', default=None, help='Path to a file to open. File will be created if it doesn\'t exist.')
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ if DEVELOPMENT:
|
|||||||
# while working on the project.
|
# while working on the project.
|
||||||
update_cli_help_on_readme()
|
update_cli_help_on_readme()
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args([]) if PYTEST else parser.parse_args()
|
||||||
"""Parsed command line arguments."""
|
"""Parsed command line arguments."""
|
||||||
|
|
||||||
def get_help_text() -> str:
|
def get_help_text() -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user