]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/lib/test/test_run_and_expect.py
2 # SPDX-License-Identifier: ISC
5 # test_run_and_expect.py
6 # Tests for library function: run_and_expect(_type)().
8 # Copyright (c) 2019 by
9 # Network Device Education Foundation, Inc. ("NetDEF")
13 Tests for the `run_and_expect(_type)()` functions.
20 # Save the Current Working Directory to find lib files.
21 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
22 sys
.path
.append(os
.path
.join(CWD
, "../../"))
24 # pylint: disable=C0413
25 from lib
.topotest
import run_and_expect_type
28 def test_run_and_expect_type():
29 "Test basic `run_and_expect_type` functionality."
32 "Test function that returns `True`."
36 success
, value
= run_and_expect_type(
37 return_true
, bool, count
=1, wait
=0, avalue
=True
39 assert success
is True
43 success
, value
= run_and_expect_type(
44 return_true
, bool, count
=1, wait
=0, avalue
=False
46 assert success
is False
50 success
, value
= run_and_expect_type(return_true
, bool, count
=1, wait
=0)
51 assert success
is True
55 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0)
56 assert success
is False
59 # Test type failure, return correct type.
60 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0, avalue
=True)
61 assert success
is False
65 if __name__
== "__main__":
66 sys
.exit(pytest
.main())