Skip to content

Commit fc724b6

Browse files
committed
Enhance Boolean argument handling docs.
- Documentation in UG was outdated. - Small enhancement also to BuiltIn doc.
1 parent 711dfca commit fc724b6

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

doc/userguide/src/Appendices/BooleanArguments.rst

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ Boolean arguments
33

44
Many keywords in Robot Framework `standard libraries`_ accept arguments that
55
are handled as Boolean values true or false. If such an argument is given as
6-
a string, it is considered false if it is either empty or case-insensitively
7-
equal to `false` or `no`. Other strings are considered true regardless
8-
their value, and other argument types are tested using same `rules as in
9-
Python`__.
6+
a string, it is considered false if it is an empty string or equal to
7+
`FALSE`, `NONE`, `NO`, `OFF` or `0`, case-insensitively. Other
8+
strings are considered true unless the keyword documentation explicitly
9+
states otherwise, and other argument types are tested using the same
10+
`rules as in Python`__.
1011

1112
__ http://docs.python.org/library/stdtypes.html#truth-value-testing
1213

13-
Keyword can also accept other special strings than `false` and `no` that are
14-
to be considered false. For example, BuiltIn_ keyword `Should Be True` used
15-
in the examples below considers string `no values` given to its `values`
16-
argument as false.
17-
1814
.. sourcecode:: robotframework
1915

2016
*** Keywords ***
@@ -29,8 +25,7 @@ argument as false.
2925
Should Be Equal ${x} ${y} Custom error values=no # Also string `no` is false.
3026
Should Be Equal ${x} ${y} Custom error values=${EMPTY} # Empty string is false.
3127
Should Be Equal ${x} ${y} Custom error values=${FALSE} # Python `False` is false.
32-
Should Be Equal ${x} ${y} Custom error values=no values # Special false string in this context.
28+
Should Be Equal ${x} ${y} Custom error values=no values # Special false string with this keyword.
3329

34-
Note that prior to Robot Framework 2.9 handling Boolean arguments was
35-
inconsistent. Some keywords followed the above rules, but others simply
36-
considered all non-empty strings, including `false` and `no`, to be true.
30+
.. note:: Considering string `NONE` false is new in Robot Framework 3.0.3 and
31+
considering also `OFF` and `0` false is new in Robot Framework 3.1.

src/robot/libraries/BuiltIn.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,8 +3345,9 @@ class BuiltIn(_Verify, _Converter, _Variables, _RunKeyword, _Control, _Misc):
33453345
it is an empty string or equal to ``FALSE``, ``NONE``, ``NO``, ``OFF`` or
33463346
``0``, case-insensitively. Keywords verifying something that allow dropping
33473347
actual and expected values from the possible error message also consider
3348-
string ``no values`` to be false. Other strings are considered true
3349-
regardless their value, and other argument types are tested using the same
3348+
string ``no values`` to be false. Other strings are considered true unless
3349+
the keyword documentation explicitly states otherwise, and other argument
3350+
types are tested using the same
33503351
[http://docs.python.org/library/stdtypes.html#truth|rules as in Python].
33513352
33523353
True examples:

0 commit comments

Comments
 (0)