New developer: how to run tox?

I’ve created my first PR for Home Assistant, and am now trying to get through the checklist that appears when I create the PR in github.

I spent a while stuck on the step:

  • [ ] Local tests pass with tox. Your PR cannot be merged unless tests pass

So I read the documentation for tox, and I was left feeling I didn’t have enough information to properly run this tool. So I wanted to update this documentation so others would not have the same trouble I did. But first… did I get it right?

First off – what does a successful tox run look like? Are there expected error messages, or should the reams of output from this tool not include the string “error”? The documentation doesn’t say… Now that I think I got it to run correctly, I think the string I’m looking for is “congratulations :)”. Is that correct? (There are still some warnings I’m unsure how to eliminate. Are they important?)

I tried running tox on the Raspberry Pi 3 I use for development, but it seemed to take forever. So I ran it on a VM on my desktop (which is a fairly beefy system), and it finished in just over 1.5 hours, and consumed 5GB of disk space (I had to increase my VM’s drive size and re-run to get it to complete). Is this as expected?

The script I created to run tox from a clean repository (just to make sure it was working) is here.

The output I got from tox is here.



I honestly didn’t read your tox log closely, but if you got a congratulations, then it passed everything it tested, which might not include all python versions. I’m somewhat surprised it consumed so much storage, but the full test suite requires the installation/download of all test packages which will take a long time. You won’t have to redownload them all a second time, but it will still take awhile.

I recommend using the script/lazytox as it will only test and lint the files you touched as opposed to everything.

Assuming that you are working within a particular component and not the core, I’d recommend only running the tests that are specific to that component - single file or set of files. You can normally also limit tox to a single Python version. Have a look at this part of the doco:

Then you can use a service like Travis CI to have all the tests run automatically. You can sign up for free and point it to your own HA fork, and it will build and test at each commit.

Thank you! I’ve submitted a PR to update the docs here.