Skip to content

Commit cc75c7f

Browse files
Merge pull request #1147 from silx-kit/test_as_variable
add "--test" argument to start pymca in test mode (mainly for CI)
2 parents 2e7375b + 67e5990 commit cc75c7f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PyMca5/PyMcaGui/pymca/PyMcaMain.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
'nativefiledialogs=',
5050
'PySide=',
5151
'binding=',
52-
'logging=']
52+
'logging=',
53+
'test']
5354
try:
5455
opts, args = getopt.getopt(
5556
sys.argv[1:],
@@ -99,6 +100,19 @@
99100
import PyQt6.QtCore
100101
else:
101102
raise ValueError("Unknown Qt binding <%s>" % binding)
103+
elif opt in ('--test'):
104+
try:
105+
from PyMca5.tests import TestAll
106+
print("Running PyMca Unit Tests...")
107+
result = TestAll.main()
108+
exit_code = 0 if result.wasSuccessful() else 1
109+
print('exit code: ', exit_code)
110+
sys.exit(exit_code)
111+
except Exception as e:
112+
import traceback
113+
print("Failed to run tests:", e)
114+
traceback.print_exc()
115+
sys.exit(1)
102116

103117
from PyMca5.PyMcaCore.LoggingLevel import getLoggingLevel
104118
logging.basicConfig(level=getLoggingLevel(opts))

0 commit comments

Comments
 (0)