sphinxcontrib.argdoc.test.test_argdoc module

Test suite for sphinxcontrib.argdoc.

Test implementation

To add a test case for a new argparse configuration

  1. Create an executable script using argparse following the general form of the other tests. Put it in the subpackage sphinxcontrib.argdoc.test.cases
  2. Create a matching rst document stub, and put it into sphinxcontrib/argdoc/test/testdocroot
  3. Add an entry for the rst document stub in sphinxcontrib/argdoc/test/testdocroot/master_toctree.rst
class sphinxcontrib.argdoc.test.test_argdoc.TestArgdoc[source]

Test case for functions defined in sphinxcontrib.argdoc.ext

Methods

check_equal(expected, found[, casename]) Helper method just to allow us to use test generators in other tests
check_list_equal(l1, l2, test_name)
check_not_match(pattern, inp, msg)
check_pattern(test_name, pat, inp, expected) Check patterns for matching, or non-matching
run_builder() Run sphinx builder only the first time it is needed
setUpClass()
tearDownClass() Clean up temp files after tests are complete
test_format_argparser_as_docstring()
test_get_col1_text()
test_get_col2_text()
test_make_rest_table_with_indent()
test_make_rest_table_with_title()
test_make_rest_table_without_title()
test_noargdoc_adds_attribute()
test_patterns()
test_post_process_automodule()
test_post_process_automodule_emits_event()
test_prefix_chars_does_not_match_wrong()
test_prefix_chars_does_not_mix()
test_prefix_chars_matches()
classmethod setUpClass()[source]
classmethod tearDownClass()[source]

Clean up temp files after tests are complete

classmethod run_builder()[source]

Run sphinx builder only the first time it is needed

Raises:

AssertionError

If builder exists with non-zero status

static check_pattern(test_name, pat, inp, expected)[source]

Check patterns for matching, or non-matching

Parameters:

test_name : str

Name of test set being executed

pat : re.compile

Pattern to test

inp : str

Input to test

expected : dict, tuple, or None

Expected result. If a dict, equivalence is tested with pat.match(inp).groupdict() is called to test equivalence. If a ‘tuple’ equivalence is tested with pat.match(inp).groups(), re.compile.groups() is called. If None, it is asserted that pat.match(inp) is None

test_patterns()[source]
static check_equal(expected, found, casename='')[source]

Helper method just to allow us to use test generators in other tests

test_prefix_chars_matches()[source]
static check_not_match(pattern, inp, msg)[source]
test_prefix_chars_does_not_match_wrong()[source]
test_prefix_chars_does_not_mix()[source]
test_get_col1_text()[source]
test_get_col2_text()[source]
test_make_rest_table_with_title()[source]
test_make_rest_table_without_title()[source]
test_make_rest_table_with_indent()[source]
test_noargdoc_adds_attribute()[source]
static check_list_equal(l1, l2, test_name)[source]
test_format_argparser_as_docstring()[source]
test_post_process_automodule()[source]
test_post_process_automodule_emits_event()[source]
class sphinxcontrib.argdoc.test.test_argdoc.Record[source]

Bases: object

Proxy object that allows addition of arbitrary properties

__init__()[source]
class sphinxcontrib.argdoc.test.test_argdoc.FakeApp(argdoc_main_func='main', argdoc_save_rst=True, outdir='/tmp/', argdoc_prefix_chars='-')[source]

Bases: object

Proxy for a Sphinx application object. Implements minimial methods required for us to test functions in sphinxcontrib.argdoc.ext that require a Sphinx application instance

Methods

debug(*args, **kwargs)
debug2(*args, **kwargs)
emit(*args, **kwargs) Simulate emit method.
warn(*args, **kwargs)
__init__(argdoc_main_func='main', argdoc_save_rst=True, outdir='/tmp/', argdoc_prefix_chars='-')[source]
warn(*args, **kwargs)[source]
debug(*args, **kwargs)[source]
debug2(*args, **kwargs)[source]
emit(*args, **kwargs)[source]

Simulate emit method. Save event name in self.emitted at each call