]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/lib/test/test_run_and_expect.py
4 # test_run_and_expect.py
5 # Tests for library function: run_and_expect(_type)().
7 # Copyright (c) 2019 by
8 # Network Device Education Foundation, Inc. ("NetDEF")
10 # Permission to use, copy, modify, and/or distribute this software
11 # for any purpose with or without fee is hereby granted, provided
12 # that the above copyright notice and this permission notice appear
15 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
19 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
21 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 Tests for the `run_and_expect(_type)()` functions.
33 # Save the Current Working Directory to find lib files.
34 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
35 sys
.path
.append(os
.path
.join(CWD
, "../../"))
37 # pylint: disable=C0413
38 from lib
.topotest
import run_and_expect_type
41 def test_run_and_expect_type():
42 "Test basic `run_and_expect_type` functionality."
45 "Test function that returns `True`."
49 success
, value
= run_and_expect_type(
50 return_true
, bool, count
=1, wait
=0, avalue
=True
52 assert success
is True
56 success
, value
= run_and_expect_type(
57 return_true
, bool, count
=1, wait
=0, avalue
=False
59 assert success
is False
63 success
, value
= run_and_expect_type(return_true
, bool, count
=1, wait
=0)
64 assert success
is True
68 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0)
69 assert success
is False
72 # Test type failure, return correct type.
73 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0, avalue
=True)
74 assert success
is False
78 if __name__
== "__main__":
79 sys
.exit(pytest
.main())