Test definition¶
Module tests¶
Tests of pyyc.mod functions, to be run with pytest:
$ pytest -v test_mod.py
Ideally, each function and use case should be tested: standard use (as described in documentation), invalid use (handled with documented exceptions), corner cases, etc.
@pytest.mark.parametrize decorator allows to easily test different inputs/outputs pairs;
capsys captures standard and error outputs (e.g. from
print());monkeypatch overrides modules and environments (e.g. here
input()).
Note
Some parts of the code are voluntarily left untested to be used as
example in coverage report.
- tests.test_mod.test_addition_int_list()[source]¶
Single test of
pyyc.mod.addition()on list of int.
- tests.test_mod.test_addition_str_list()[source]¶
Single test of
pyyc.mod.addition()on list of str.
- tests.test_mod.test_addition_parametrized(test_input, expected_output)[source]¶
Test standard usage of
pyyc.mod.addition().This test uses parametrization of arguments, see How to parametrize fixtures and test functions.
Tip
addition(*args)will unpack the arguments on-the-fly and is similar toaddition(args[0], args[1], ...).
- tests.test_mod.test_addition_TypeError(test_input)[source]¶
Test incompatible argument case.
It should raise
TypeError, as mentioned in documentation ofpyyc.mod.addition().
- tests.test_mod.test_addition_empty()[source]¶
Test no argument case.
It should raise
IndexError, not documented.
- tests.test_mod.test_read_config_content(capsys)[source]¶
Test full content of configuration file.
This test uses stdout capture, see How to capture stdout/stderr output.
- tests.test_mod.test_read_config_IOError()[source]¶
Test non-existing or invalid configuration files.
- tests.test_mod.test_format_pkg_tree()[source]¶
Test standard usage of
pyyc.mod.format_pkg_tree().