Commit b7ffddf2 authored by ∞'s avatar 💻

Got to 88% coverage in 2 minutes ^^

parent d81e534c
Pipeline #1794 failed with stages
in 16 seconds
......@@ -201,11 +201,11 @@ def help(*args):
elif importable.module:
if not importable.target:
yield f'{RED}Cannot import {args[0]}{RESET}'
yield ' '.join(
yield ' '.join([
YELLOW,
'Showing help for',
importable.module.__name__ + RESET
)
])
yield Group.factory(importable.module.__name__).doc
......@@ -328,12 +328,12 @@ def run(callback, *args, **kwargs):
else:
return f'Docstring not found in {cb.module.__name__}'
elif callback != callback.split('.')[0]:
yield ' '.join(
yield ' '.join([
RED,
'Could not import module:',
callback.split(".")[0],
callback.split('.')[0],
RESET,
)
])
class Parser:
......
......@@ -10,11 +10,20 @@ import pytest
('run_help', 'run cli2.help'),
('run_help_debug', 'run cli2.help debug'),
('run_help_implicit', 'cli2.help'),
('run_module', 'cli2'),
('run_module_missing_attr', 'cli2.missing'),
('run_module_missing', 'missinggggggg.foo'),
('run_module_nodoc', 'test_cli2.test_cli2'),
('help_module', 'help pytest'),
('help_module_attr', 'help pytest.skip'),
('help_module_attr_notfound', 'help pytest.skipppp'),
('docmod', 'docmod cli2'),
('docmod_noargs', 'docmod'),
('docfile', 'docfile cli2.py'),
('docfile_missing', 'docfile cli2aoeuoeauoaeu.py'),
('debug', 'debug cli2.run to see=how -it --parses=me'),
])
def test_djcli(name, command):
def test_cli2(name, command):
cli2.autotest(
f'tests/{name}.txt',
'cli2 ' + command,
......
command: cli2 docfile cli2aoeuoeauoaeu.py
retcode: 1
stdout:
cli2aoeuoeauoaeu.py not found
command: cli2 docmod
retcode: 1
stdout:
Missing arguments: module_name
Signature: docmod(module_name)
Docstring for a module in dotted path.
Example: cli2 docmod cli2
command: cli2 help pytest
retcode: 1
stdout:
pytest: unit and functional testing with Python.
help Get help for a command.
approx Assert that two numbers (or two sets of numbers) are equal to each other
deprecated_call context manager that can be used to ensure a block of code triggers a
ensuretemp (deprecated) return temporary directory path with
exit Exit testing process as if KeyboardInterrupt was triggered.
fail Explicitly fail an executing test with the given message.
fixture Decorator to mark a fixture factory function.
freeze_includes Returns a list of module names used by pytest that should be
hookimpl Decorator helper class for marking functions as hook implementations.
hookspec Decorator helper class for marking functions as hook specifications.
importorskip return imported module if it has at least "minversion" as its
main return exit code, after performing an in-process test run.
param Specify a parameter in `pytest.mark.parametrize`_ calls or
raises Assert that a code block/function call raises ``expected_exception``
register_assert_rewrite Register one or more module names to be rewritten on import.
set_trace invoke PDB set_trace debugging, dropping any IO capturing.
skip Skip an executing test with the given message.
warns Assert that code raises a particular class of warning.
xfail Imperatively xfail an executing test or setup functions with the given reason.
yield_fixture (return a) decorator to mark a yield-fixture factory function.
command: cli2 help pytest.skip
retcode: 1
stdout:
Signature: pytest.skip(msg='', **kwargs)
Skip an executing test with the given message.
This function should be called only during testing (setup, call or teardown) or
during collection by using the ``allow_module_level`` flag.
:kwarg bool allow_module_level: allows this function to be called at
module level, skipping the rest of the module. Default to False.
.. note::
It is better to use the :ref:`pytest.mark.skipif ref` marker when possible to declare a test to be
skipped under certain conditions like mismatching platforms or
dependencies.
command: cli2 help pytest.skipppp
retcode: 1
stdout:
Cannot import pytest.skipppp
Showing help for pytest
pytest: unit and functional testing with Python.
help Get help for a command.
approx Assert that two numbers (or two sets of numbers) are equal to each other
deprecated_call context manager that can be used to ensure a block of code triggers a
ensuretemp (deprecated) return temporary directory path with
exit Exit testing process as if KeyboardInterrupt was triggered.
fail Explicitly fail an executing test with the given message.
fixture Decorator to mark a fixture factory function.
freeze_includes Returns a list of module names used by pytest that should be
hookimpl Decorator helper class for marking functions as hook implementations.
hookspec Decorator helper class for marking functions as hook specifications.
importorskip return imported module if it has at least "minversion" as its
main return exit code, after performing an in-process test run.
param Specify a parameter in `pytest.mark.parametrize`_ calls or
raises Assert that a code block/function call raises ``expected_exception``
register_assert_rewrite Register one or more module names to be rewritten on import.
set_trace invoke PDB set_trace debugging, dropping any IO capturing.
skip Skip an executing test with the given message.
warns Assert that code raises a particular class of warning.
xfail Imperatively xfail an executing test or setup functions with the given reason.
yield_fixture (return a) decorator to mark a yield-fixture factory function.
command: cli2 cli2
retcode: 1
stdout:
Cannot run a module: try cli2.something
However we could import module cli2
Showing help for cli2:
cli2 makes your python callbacks work on CLI too !
cli2 provides sub-commands to introspect python modules or callables docstrings
or to execute callables or help working with cli2 itself.
help Get help for a command.
config config(**config)
debug Dump parsed variables.
docfile Docstring for a file path.
docmod Docstring for a module in dotted path.
run Execute a python callback on the command line.
command: cli2 missinggggggg.foo
retcode: 1
stdout:
Could not import callback: missinggggggg.foo
Could not import module: missinggggggg
command: cli2 cli2.missing
retcode: 1
stdout:
Could not import callback: cli2.missing
However we could import module cli2
Showing help for cli2:
cli2 makes your python callbacks work on CLI too !
cli2 provides sub-commands to introspect python modules or callables docstrings
or to execute callables or help working with cli2 itself.
help Get help for a command.
config config(**config)
debug Dump parsed variables.
docfile Docstring for a file path.
docmod Docstring for a module in dotted path.
run Execute a python callback on the command line.
command: cli2 test_cli2.test_cli2
retcode: 1
stdout:
Missing arguments: name, command
Signature: test_cli2.test_cli2(name, command)
No docstring found
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment