-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Test.py
48 lines (35 loc) · 1.24 KB
/
Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from unittest import TestLoader, TestResult, TextTestRunner
from pathlib import Path
import bpy
def run_tests():
test_loader = TestLoader()
test_directory = str(Path(__file__).resolve().parent / 'tests')
test_suite = test_loader.discover(test_directory, pattern='test_*.py')
runner = TextTestRunner(verbosity=2)
result = runner.run(test_suite)
return result
class YRunAutomatedTest(bpy.types.Operator):
bl_idname = "node.y_run_automated_test"
bl_label = "Run Automated Test"
bl_options = {'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
wm = context.window_manager
wmyp = wm.ypprops
# Reset test results
wmyp.test_result_run = 0
wmyp.test_result_error = 0
wmyp.test_result_failed = 0
# Run tests
result = run_tests()
# Set test results
wmyp.test_result_run = result.testsRun
wmyp.test_result_error = len(result.errors)
wmyp.test_result_failed = len(result.failures)
return {'FINISHED'}
def register():
bpy.utils.register_class(YRunAutomatedTest)
def unregister():
bpy.utils.unregister_class(YRunAutomatedTest)