Python Plugin how to use pytest

Python and python framework

Moderator: leecollings

Post Reply
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Python Plugin how to use pytest

Post 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?
User avatar
waltervl
Posts: 7005
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2026.3
Location: NL
Contact:

Re: Python Plugin how to use pytest

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: Python Plugin how to use pytest[solved]

Post 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
Post Reply