Static analysis for your test scripts: Catching common mistakes before you run the tests!
23 Jan 2020.
Pylint is a static analysis tool for Python code. This means that it analyses your code to catch common mistakes, without actually running your code. This saves a lot of development time by catching the mistakes immediately —your IDE shows red squiggles under each mistake— instead of running the test and waiting for it to reach the line of code where the mistake is.
Stb-tester provides a Pylint plugin that teaches Pylint about some mistakes that are specific to Stb-tester APIs. For example, the frame parameter of stbt.match is usually optional, but it’s mandatory when called inside a FrameObject property:
Another common mistake is using a reference image that doesn’t exist on disk, or that hasn’t been committed to git:
Some Stb-tester APIs raise an exception on failure (for example stbt.wait_for_match) but others don’t (for example stbt.match and stbt.wait_until, among others). This can be confusing, so we report an error if you forget to use the return value from the latter group of APIs:
In some rare cases you might want to ignore the return value for a valid reason. You can disable the warning for that specific line, by adding a comment:
Some of Pylint’s built-in checks are related to coding style, not real
problems. If they get annoying you can disable specific checks by listing them
.pylintrc file in the root of your test-pack. For example:
The name of each checker (such as “line-too-long”) is shown after the error message in your IDE.
To set up your IDE to catch all of these errors, see IDE Configuration in the Stb-tester manual.
If you’re curious about the full list of checks that Stb-tester adds to Pylint, see the source code of our Pylint plugin here.