Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc/update interactive & assertions doc #1127

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions doc/en/assertions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ a testcase, because it avoids the typical problem of fixing one assertion simply
to find another one later on.

If some assertions rely on the result of previous ones and does not make sense
to be executed if the previous failed, their boolean return values can be used
like this example:
to be executed if the previous failed, the ``passed`` attribute of the returned
assertion entry can be used like this example:

.. code-block:: python

@testcase
def sample_testcase(self, env, result):
item = get_item()
passed = result.true(isinstance(item, dict), description='Check if dict')
if passed is True:
entry = result.true(isinstance(item, dict), description='Check if dict')
if entry.passed is True:
result.contain('key', item.keys(), description='.keys() used')

If the test should be stopped on an assertion failure, an exception can be raised
Expand All @@ -44,9 +44,9 @@ or use a *return* statement like this example:

@testcase
def sample_testcase(self, env, result):
passed = result.true(isinstance(5, float), description='Check if float')
entry = result.true(isinstance(5, float), description='Check if float')

if passed is False:
if entry.passed is False:
raise RuntimeError('5 is not a float.')
# Or
result.log('5 is not a float. Aborting testcase.')
Expand Down
15 changes: 13 additions & 2 deletions doc/en/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ circumstances.
* ``__main__`` module (i.e. test_plan.py) cannot be reloaded. Because of this,
it is recommended that test suites are defined in seperate modules. It is a
good idea to keep the main script simple.
* Testplan is not able to reload module that is under *Namespace Package*, the
workaround is to add dummy __init__.py file.
* Testplan is not able to reload module that is under **Namespace Package**, the
workaround is to add dummy ``__init__.py`` file.
* Unlike testcases that can be added/removed/modified, adding/removing/renaming
testsuite class will not take effect after reloading.
* Modules or objects imported using ``from some_module import *`` syntax are
Expand All @@ -73,6 +73,17 @@ circumstances.
* In interactive mode, all modules containing test targets will be loaded at
the same time, if the modules from which tasks are scheduled have the same
name, they won't be reloaded properly.
* `modulefinder.ModuleFinder <https://docs.python.org/3/library/modulefinder.html#modulefinder.ModuleFinder>`_
works purely on static analysis, which means it can handle the following cases
in the current module:

* Absolute import from the top-level package containing the current module.
* Relative import from the current module to its sibling modules.

It is completely ignorant of any programmatic import as well as import
requiring ``sys.path`` manipulation. Such dependencies will not be included
in the graph thus not reloaded. User can use the ``extra_deps`` parameter of
the ``@test_plan`` decorator to specify these dependencies manually.


.. _Interactive_UI:
Expand Down