Page 1 of 1

Python Plugin how to use pytest

Posted: Monday 22 March 2021 21:33
by Flopp
I have written 2 plugins for Domoticz. I am using github.com for my code.

Now I want to be able to run some tests on my plugins.

I want to start with flake8, this is a test that check if your code is with "correct" design, like 4 space indent.

The problem that I have is that flake8 is also checking that a variable is defined, which Parameters[""] isn't, because that variable is coming from Domoticz.

Anyone that have written a plugin and have a working workflow for Github?

Re: Python Plugin how to use pytest

Posted: Monday 22 March 2021 21:53
by waltervl
You better post this in the Python section..
I saw a merge by @cclaus about lint, perhaps he knows the answer https://github.com/domoticz/domoticz/pull/4720

There is also an issue on github mentioning the same issue (I think....).
https://github.com/domoticz/domoticz/issues/4724

Re: Python Plugin how to use pytest[solved]

Posted: Monday 22 March 2021 22:05
by Flopp
waltervl wrote: Monday 22 March 2021 21:53 You better post this in the Python section..
I saw a merge by @cclaus about lint, perhaps he knows the answer https://github.com/domoticz/domoticz/pull/4720

There is also an issue on github mentioning the same issue (I think....).
https://github.com/domoticz/domoticz/issues/4724
Thank you. Claus started to help me with this problem but I never understood him :( , then he started to do some changes for Domoticz workflows.

You were right, I found the solution in his merge request, thank you for getting me to look at Claus code again :)

Code: Select all

from Domoticz import Devices, Parameters
was the solution