eric7/eric7_unittest.py

branch
eric7
changeset 8312
800c432b34c8
parent 8258
82b608e352ec
child 8314
e3642a6a1e71
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 eric Unittest.
9
10 This is the main Python script that performs the necessary initialization
11 of the unittest module and starts the Qt event loop. This is a standalone
12 version of the integrated unittest module.
13 """
14
15 import sys
16 import os
17
18 sys.path.insert(1, os.path.dirname(__file__))
19
20 for arg in sys.argv[:]:
21 if arg.startswith("--config="):
22 import Globals
23 configDir = arg.replace("--config=", "")
24 Globals.setConfigDir(configDir)
25 sys.argv.remove(arg)
26 elif arg.startswith("--settings="):
27 from PyQt5.QtCore import QSettings
28 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
29 if not os.path.isdir(settingsDir):
30 os.makedirs(settingsDir)
31 QSettings.setPath(
32 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir)
33 sys.argv.remove(arg)
34
35 from Globals import AppInfo
36
37 from Toolbox import Startup
38
39
40 def createMainWidget(argv):
41 """
42 Function to create the main widget.
43
44 @param argv list of commandline parameters (list of strings)
45 @return reference to the main widget (QWidget)
46 """
47 from PyUnit.UnittestDialog import UnittestWindow
48 try:
49 fn = argv[1]
50 except IndexError:
51 fn = None
52 return UnittestWindow(fn)
53
54
55 def main():
56 """
57 Main entry point into the application.
58 """
59 from PyQt5.QtGui import QGuiApplication
60 QGuiApplication.setDesktopFileName("eric6_unittest.desktop")
61
62 options = [
63 ("--config=configDir",
64 "use the given directory as the one containing the config files"),
65 ("--settings=settingsDir",
66 "use the given directory to store the settings files"),
67 ]
68 appinfo = AppInfo.makeAppInfo(sys.argv,
69 "eric Unittest",
70 "file",
71 "Graphical unit test application",
72 options)
73 res = Startup.simpleAppStartup(sys.argv,
74 appinfo,
75 createMainWidget)
76 sys.exit(res)
77
78 if __name__ == '__main__':
79 main()

eric ide

mercurial