Skip to content

Commit

Permalink
docs: Add a test example written in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
kalikiana committed Jul 14, 2021
1 parent e6131fe commit 703ed99
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/WritingTests.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,37 @@ sub run() {
}
--------------------------------------------------------------

In addition to Perl, it is possible to write tests in Python. Although the
boilerplate is slightly different the function names are the same.

[caption="Example: "]
.Test for the openQA web UI written in Python
[source,python]
--------------------------------------------------------------
from testapi import *
def run(self):
assert_screen('openqa-logged-in')
assert_and_click('openqa-search')
type_string('shutdown.pm')
send_key('ret')
assert_screen('openqa-search-results')
def switch_to_root_console():
send_key('ctrl-alt-f3')
def post_fail_hook(self):
switch_to_root_console()
assert_script_run('openqa-cli api experimental/search q=shutdown.pm')
def test_flags(self):
return {'fatal': 1}
--------------------------------------------------------------

== Variables

Test case behavior can be controlled via variables. Some basic
Expand Down

0 comments on commit 703ed99

Please sign in to comment.