I'm using Squish 6.4.2 to test my Qt applications, using Python 2.7.10 as the test scripting language and got the following error message when trying to use the range()
function:
TypeError: range() integer end argument expected, got int.
Here's a small code example and my output in Squish:
def main():
test.log(str(range(4)))
test.log(str(range(int(4))))
[0, 1, 2, 3]
Error: Script Error
Detail: TypeError: range() integer end argument expected, got int.
As you can see range(4)
works but range(int(4))
doesn't.
I've tried running the same code in the Python console of the Python version that is shipped with the Squish application, and there both range()
calls work.
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> range(4)
[0, 1, 2, 3]
>>> range(int(4))
[0, 1, 2, 3]
>>>
Also when I compare integers to a casted int the comparison result is wrong in Squish. For example in Squish:
def main():
test.log(str(7<4))
test.log(str(7 < int(4)))
gives
False
True
In the Python console the result is correct though.
The Squish int is different from the Python int:
Squish's int represents the Squish type for an integer in the wrapper's C and C++ code.
Like the other hidden symbols, to access Python's int() function one can use it from the package __builtin__ (Python 2) or builtins (Python 3).
(Other types are different as well)
See Squish's int vs. Python's int
Or more generally Python Notes in the Squish manual.