Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Unknown qExec() in QtTest for Python testcases?
Forum Update on Monday, May 27th 2025

Unknown qExec() in QtTest for Python testcases?

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 175 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.
  • P Offline
    P Offline
    PowerNow
    wrote on 24 Sept 2021, 07:38 last edited by
    #1

    Hi, I want to use QtTest for C++ and Python. In C++ I use

    #include <QtTest/QtTest>
    #include <Test/testcases.h>
    
    int main(int argc, char *argv[])
    {
        TestCases testcases;
        return QTest::qExec(&testcases, argc, argv);
    }
    

    and it works great. Unfortunately in Python it does not

    from PySide6.QtTest import QTest
    import testcases
    
    testcases = testcases.TestCases()
    QTest.qExec(testcases)
    

    and get the error

    AttributeError: type object 'PySide6.QtTest.QTest' has no attribute 'qExec'
    

    Although in the Qt Python docu stands

    qExec() can be used to execute all test functions in the test object.
    

    https://doc.qt.io/qtforpython/overviews/qtest-overview.html#miscellaneous-options

    What I'm doing wrong here? Thks...

    E 1 Reply Last reply 24 Sept 2021, 07:48
    0
    • P PowerNow
      24 Sept 2021, 07:38

      Hi, I want to use QtTest for C++ and Python. In C++ I use

      #include <QtTest/QtTest>
      #include <Test/testcases.h>
      
      int main(int argc, char *argv[])
      {
          TestCases testcases;
          return QTest::qExec(&testcases, argc, argv);
      }
      

      and it works great. Unfortunately in Python it does not

      from PySide6.QtTest import QTest
      import testcases
      
      testcases = testcases.TestCases()
      QTest.qExec(testcases)
      

      and get the error

      AttributeError: type object 'PySide6.QtTest.QTest' has no attribute 'qExec'
      

      Although in the Qt Python docu stands

      qExec() can be used to execute all test functions in the test object.
      

      https://doc.qt.io/qtforpython/overviews/qtest-overview.html#miscellaneous-options

      What I'm doing wrong here? Thks...

      E Offline
      E Offline
      eyllanesc
      wrote on 24 Sept 2021, 07:48 last edited by
      #2

      @PowerNow If you are going to implement test in python then it is better to use pytest-qt as it uses pytest + QtTest environment (internally): https://pypi.org/project/pytest-qt/

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      1

      1/2

      24 Sept 2021, 07:38

      • Login

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