Testing a non-boolean variable in an expression is evaluated as a boolean which for a string is True if the String is not None and is not an empty string; e.g. bool('test') = True; bool('') = False; bool(None) = False.
By default, an object is considered true unless its class defines either a bool() method that returns False or a len() method that returns zero, when called with the object. See built-in types.
z = 'Test'
x = 'Test1234'
z and x == 'Test' # False
x and z == 'Test' # True
The expression x and z == 'Test'
using operator precedence is evaluated as x and (z == 'Test')
-- adding ()'s for clarity. The lone 'x' is evaluated as a boolean expression so is the same as bool(x)
so the expression then becomes bool(x) and (z == 'Test')
.
This is evaluated as True and ('Test' == 'Test')
or True and True
or just True.