Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Testing PyQt (or Qt) Applications, Design of Classes and the Use of Private Functions and Attributes
Forum Updated to NodeBB v4.3 + New Features

Testing PyQt (or Qt) Applications, Design of Classes and the Use of Private Functions and Attributes

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 347 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lvlanson
    wrote on last edited by
    #1

    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

    test.png

    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?

    JonBJ 1 Reply Last reply
    0
    • L lvlanson

      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

      test.png

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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.

      1 Reply Last reply
      1
      • L Offline
        L Offline
        lvlanson
        wrote on last edited by
        #3

        Thank you, I was not really familiar with this aspect of Python3

        JonBJ 1 Reply Last reply
        0
        • L lvlanson

          Thank you, I was not really familiar with this aspect of Python3

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved