|
1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 Eric6 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 from __future__ import unicode_literals |
|
16 |
|
17 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__ |
|
18 |
|
19 try: # Only for Py2 |
|
20 import Globals.compatibility_fixes # __IGNORE_WARNING__ |
|
21 except (ImportError): |
|
22 pass |
|
23 |
|
24 import sys |
|
25 import os |
|
26 |
|
27 for arg in sys.argv[:]: |
|
28 if arg.startswith("--config="): |
|
29 import Globals |
|
30 configDir = arg.replace("--config=", "") |
|
31 Globals.setConfigDir(configDir) |
|
32 sys.argv.remove(arg) |
|
33 elif arg.startswith("--settings="): |
|
34 from PyQt5.QtCore import QSettings |
|
35 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
|
36 if not os.path.isdir(settingsDir): |
|
37 os.makedirs(settingsDir) |
|
38 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope, |
|
39 settingsDir) |
|
40 sys.argv.remove(arg) |
|
41 |
|
42 from Globals import AppInfo |
|
43 |
|
44 from Toolbox import Startup |
|
45 |
|
46 # make Third-Party package available as a packages repository |
|
47 sys.path.insert(2, os.path.join(os.path.dirname(__file__), |
|
48 "ThirdParty", "EditorConfig")) |
|
49 |
|
50 |
|
51 def createMainWidget(argv): |
|
52 """ |
|
53 Function to create the main widget. |
|
54 |
|
55 @param argv list of commandline parameters (list of strings) |
|
56 @return reference to the main widget (QWidget) |
|
57 """ |
|
58 from PyUnit.UnittestDialog import UnittestWindow |
|
59 try: |
|
60 fn = argv[1] |
|
61 except IndexError: |
|
62 fn = None |
|
63 return UnittestWindow(fn) |
|
64 |
|
65 |
|
66 def main(): |
|
67 """ |
|
68 Main entry point into the application. |
|
69 """ |
|
70 options = [ |
|
71 ("--config=configDir", |
|
72 "use the given directory as the one containing the config files"), |
|
73 ("--settings=settingsDir", |
|
74 "use the given directory to store the settings files"), |
|
75 ] |
|
76 appinfo = AppInfo.makeAppInfo(sys.argv, |
|
77 "Eric6 Unittest", |
|
78 "file", |
|
79 "Graphical unit test application", |
|
80 options) |
|
81 res = Startup.simpleAppStartup(sys.argv, |
|
82 appinfo, |
|
83 createMainWidget) |
|
84 sys.exit(res) |
|
85 |
|
86 if __name__ == '__main__': |
|
87 main() |