Python Coverage suddenly dropping

Viewed 59

I'm working on a GUI written in Python using PyQt5, and I'm preparing the coverage report for SonarQube.

The coverage was initially 43%. Then it suddenly dropped after I changed the main file, called app.py. All I did was add the following:

if __name__ == "__main__":
    main()

I added this because without it, it would display the GUI when importing app.py. The main() simply instantiates the application, and also contains instructions to show the main window. With the above addition, the coverage drops to 14%. If I remove the above, the coverage goes right back to 43%. Any ideas why the coverage would suddenly drop significantly upon adding this tiny change, and how I could prevent it from dropping this much?

Versions:

  • Python 3.10.2
  • Coverage.py, version 6.3.3 with C extension
  • PyQt5 5.15.4
0 Answers
Related