src/eric7/Testing/Interfaces/UnittestRunner.py

branch
eric7-maintenance
changeset 9549
67295777d9fe
parent 9442
906485dcd210
parent 9485
0f3620304d7a
child 9654
7328efba128b
equal deleted inserted replaced
9451:24c847222774 9549:67295777d9fe
5 5
6 """ 6 """
7 Module implementing the test runner script for the 'unittest' framework. 7 Module implementing the test runner script for the 'unittest' framework.
8 """ 8 """
9 9
10 import importlib
10 import json 11 import json
11 import os 12 import os
12 import sys 13 import sys
13 import time 14 import time
14 import unittest 15 import unittest
15 16
16 sys.path.insert(2, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) 17 sys.path.insert(
18 2,
19 os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")),
20 )
21 # three times up is our installation directory
17 22
18 23
19 class EricTestResult(unittest.TestResult): 24 class EricTestResult(unittest.TestResult):
20 """ 25 """
21 Class implementing a TestResult derivative to send the data via a network 26 Class implementing a TestResult derivative to send the data via a network
355 os.path.join( 360 os.path.join(
356 os.path.dirname(__file__), "..", "..", "DebugClients", "Python" 361 os.path.dirname(__file__), "..", "..", "DebugClients", "Python"
357 ) 362 )
358 ), 363 ),
359 ) 364 )
360 from eric7.DebugClients.Python.coverage import Coverage 365 from coverage import Coverage # __IGNORE_WARNING_I10__
361 366
362 cover = Coverage(data_file=covDataFile) 367 cover = Coverage(data_file=covDataFile)
363 if coverageErase: 368 if coverageErase:
364 cover.erase() 369 cover.erase()
365 cover.start() 370 cover.start()
376 test = testLoader.loadTestsFromNames(testCases) 381 test = testLoader.loadTestsFromNames(testCases)
377 else: 382 else:
378 test = testLoader.discover(discoveryStart) 383 test = testLoader.discover(discoveryStart)
379 else: 384 else:
380 if testFileName: 385 if testFileName:
381 module = __import__(os.path.splitext(os.path.basename(testFileName))[0]) 386 module = importlib.import_module(
387 os.path.splitext(os.path.basename(testFileName))[0]
388 )
382 else: 389 else:
383 module = None 390 module = None
384 if failed: 391 if failed:
385 if module: 392 if module:
386 failed = [t.split(".", 1)[1] for t in failed] 393 failed = [t.split(".", 1)[1] for t in failed]

eric ide

mercurial