mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
Remove more docs build errors (#45364)
* orphans testing pages to avoid not-in-toctree errors * orphans various pages pending reorg * adds module_utils and special_vars to main TOC * uses a glob for scenario_guide TOC * normalize and Sentence-case headings on community pages, typos * re-orgs community TOC, adds all pages to toctree * removes scenario guides index page * adds style guide to community index * basic update to style guide * fix typo that created a new error * removes not-in-toctree from ignore errors list * leave removing files for future cleanup task
This commit is contained in:
parent
600c7ac108
commit
4264be2b18
32 changed files with 179 additions and 160 deletions
|
@ -1,3 +1,5 @@
|
|||
:orphan:
|
||||
|
||||
.. _testing_units:
|
||||
|
||||
**********
|
||||
|
@ -91,7 +93,7 @@ Structuring Unit Tests
|
|||
|
||||
Ansible drives unit tests through `pytest <https://docs.pytest.org/en/latest/>`_. This
|
||||
means that tests can either be written a simple functions which are included in any file
|
||||
name like ``test_<something>.py`` or as classes.
|
||||
name like ``test_<something>.py`` or as classes.
|
||||
|
||||
Here is an example of a function::
|
||||
|
||||
|
@ -102,23 +104,23 @@ Here is an example of a function::
|
|||
b = 23
|
||||
c = 33
|
||||
assert a + b = c
|
||||
|
||||
|
||||
Here is an example of a class::
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class AddTester(unittest.TestCase)
|
||||
|
||||
|
||||
def SetUp()
|
||||
self.a = 10
|
||||
self.b = 23
|
||||
|
||||
# this function will
|
||||
|
||||
# this function will
|
||||
def test_add()
|
||||
c = 33
|
||||
assert self.a + self.b = c
|
||||
|
||||
# this function will
|
||||
# this function will
|
||||
def test_subtract()
|
||||
c = -13
|
||||
assert self.a - self.b = c
|
||||
|
@ -127,7 +129,7 @@ Both methods work fine in most circumstances; the function-based interface is si
|
|||
quicker and so that's probably where you should start when you are just trying to add a
|
||||
few basic tests for a module. The class-based test allows more tidy set up and tear down
|
||||
of pre-requisites, so if you have many test cases for your module you may want to refactor
|
||||
to use that.
|
||||
to use that.
|
||||
|
||||
Assertions using the simple ``assert`` function inside the tests will give full
|
||||
information on the cause of the failure with a trace-back of functions called during the
|
||||
|
@ -202,9 +204,8 @@ reports.
|
|||
:doc:`testing_running_locally`
|
||||
Running tests locally including gathering and reporting coverage data
|
||||
`Python 3 documentation - 26.4. unittest — Unit testing framework <https://docs.python.org/3/library/unittest.html>`_
|
||||
The documentation of the unittest framework in python 3
|
||||
The documentation of the unittest framework in python 3
|
||||
`Python 2 documentation - 25.3. unittest — Unit testing framework <https://docs.python.org/3/library/unittest.html>`_
|
||||
The documentation of the earliest supported unittest framework - from Python 2.6
|
||||
`pytest: helps you write better programs <https://docs.pytest.org/en/latest/>`_
|
||||
The documentation of pytest - the framework actually used to run Ansible unit tests
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue