11Tutorial
22========
33
4- Let's assume you use `pytest `_ for running your tests, which is certainly a
5- good idea. Your CLI program is called ``foobar ``.
4+ Let's assume you use `pytest `_ for running your tests, which is certainly
5+ a good idea. Your CLI program is called ``foobar ``.
66
7- You have prepared a ``setup.py `` with a CLI entrypoint. For the tests you have
8- prepared a ``tests/ `` folder (outside of ``foobar/ ``, because you don't want
9- your tests to be packaged up with your application code).
7+ You have prepared a ``pyproject.toml `` file with a CLI entrypoint. For
8+ the tests you have prepared a ``tests/ `` folder (outside of ``foobar/ ``,
9+ because you don't want your tests to be packaged up with your application
10+ code).
1011
11- Then your directory layout looks somewhat like one of `our examples `_.
12+ Then your directory layout looks somewhat like one of `our CLI examples `_.
1213
1314.. note ::
1415
15- You can easily generate a CLI project of your own from one of the
16- examples of Python CLI test helpers using `Copier `_, e.g.
16+ You can easily generate a CLI project of your own from one of our
17+ CLI examples using `Copier `_, e.g.
1718
1819 .. code-block :: console
1920
20- $ copier copy gh :painless-software/python- cli-test-helpers my-cli
21+ $ copier copy gl :painless-software/cicd/app/ cli my-cli
2122
2223 .. _pytest : https://pytest.org/
23- .. _our examples :
24- https://github .com/painless-software/python- cli-test-helpers /tree/main/examples
24+ .. _our CLI examples :
25+ https://gitlab .com/painless-software/cicd/app/ cli/- /tree/main/frameworks
2526.. _Copier : https://copier.readthedocs.io/
2627
2728Functional tests
2829----------------
2930
3031Start with a simple set of functional tests:
3132
32- - Is the entrypoint script installed? (tests the configuration in your setup.py)
33- - Can this package be run as a Python module? (i.e. without having to be installed)
33+ - Is the entrypoint script installed? (tests the configuration in your
34+ ``pyproject.toml `` file)
35+ - Can this package be run as a Python module? (i.e. without having to be
36+ installed)
3437- Is command XYZ available? etc. Cover your entire CLI usage here!
3538
3639This is almost a stupid exercise: Run the command as a shell command
@@ -46,7 +49,7 @@ and inspect the exit code of the exiting process, e.g.
4649 .. code-block :: python
4750
4851 def test_entrypoint ():
49- """ Is entrypoint script installed? (setup.py )"""
52+ """ Is entrypoint script installed? (pyproject.toml )"""
5053 result = shell(' foobar --help' )
5154 assert result.exit_code == 0
5255
@@ -115,8 +118,8 @@ See more |example code (click-command)|_.
115118.. |example code (click-command) | replace :: example code
116119
117120.. _example code (argparse-cli) :
118- https://github .com/painless-software/python- cli-test-helpers /blob/main/examples /argparse/tests/test_cli.py
121+ https://gitlab .com/painless-software/cicd/app/ cli/- /blob/main/frameworks /argparse/tests/test_cli.py
119122.. _example code (click-cli) :
120- https://github .com/painless-software/python- cli-test-helpers /blob/main/examples /click/tests/test_cli.py
123+ https://gitlab .com/painless-software/cicd/app/ cli/- /blob/main/frameworks /click/tests/test_cli.py
121124.. _example code (click-command) :
122- https://github .com/painless-software/python- cli-test-helpers /blob/main/examples /click/tests/test_command.py
125+ https://gitlab .com/painless-software/cicd/app/ cli/- /blob/main/frameworks /click/tests/test_command.py
0 commit comments