]>
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
40 def test_run_and_expect_type():
41 "Test basic `run_and_expect_type` functionality."
44 "Test function that returns `True`."
48 success
, value
= run_and_expect_type(return_true
, bool, count
=1, wait
=0, avalue
=True)
49 assert success
is True
53 success
, value
= run_and_expect_type(return_true
, bool, count
=1, wait
=0, avalue
=False)
54 assert success
is False
58 success
, value
= run_and_expect_type(return_true
, bool, count
=1, wait
=0)
59 assert success
is True
63 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0)
64 assert success
is False
67 # Test type failure, return correct type.
68 success
, value
= run_and_expect_type(return_true
, str, count
=1, wait
=0, avalue
=True)
69 assert success
is False
73 if __name__
== '__main__':
74 sys
.exit(pytest
.main())