Unsolved Testing PyQt (or Qt) Applications, Design of Classes and the Use of Private Functions and Attributes
-
I am wondering what the correct approach to the use of private attributes and methods and the meaning of such for testing is. What I have learned so far is, that I put attributes and functions private, which I do not want another class to have access to. Even that I don't set getter Methods for Attributes which I do not want to reveal to the outside.
This is a simple example of such a class
So far how I understood QTest, I need access to elements such as the buttons in that example, to trigger certain actions on certain Elements.
What is the best practice approach or what are the strategies in designing such classes, so you are able to test your software, but follow best practice design?
Do I need getter Methods for the buttons?
-
@lvlanson
Just to check that you understand one thing: Python does not have any actual "private" attributes or methods. Starting a name with an underscore is just a convention to indicate you would like it to be treated as private, but it doesn't have any effect other than that "desire". So you can access these attributes/methods/variables from the outside world as they are now. -
Thank you, I was not really familiar with this aspect of Python3
-
@lvlanson
In case I'm misleading you over leading double-underscore, you should read through e.g. https://stackoverflow.com/questions/1301346/what-is-the-meaning-of-single-and-double-underscore-before-an-object-name