[Bf-blender-cvs] [5dda36d875d] soc-2020-testing-frameworks: Removed the abstract base class as there is now only 1 Helper Test class, updated deform modifiers to ModifierTest
Himanshi Kalra
noreply at git.blender.org
Wed Aug 26 21:16:12 CEST 2020
Commit: 5dda36d875db08ea8a53216510f0971dfcb88127
Author: Himanshi Kalra
Date: Thu Aug 27 00:41:20 2020 +0530
Branches: soc-2020-testing-frameworks
https://developer.blender.org/rB5dda36d875db08ea8a53216510f0971dfcb88127
Removed the abstract base class as there is now only 1 Helper Test class, updated deform modifiers to ModifierTest
===================================================================
M tests/python/deform_modifiers.py
M tests/python/modules/mesh_test.py
===================================================================
diff --git a/tests/python/deform_modifiers.py b/tests/python/deform_modifiers.py
index 9c8b26f9678..9a35ae0ad35 100644
--- a/tests/python/deform_modifiers.py
+++ b/tests/python/deform_modifiers.py
@@ -28,7 +28,7 @@ import sys
import bpy
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
-from modules.mesh_test import MeshTest, ModifierSpec, OperatorSpecObjectMode, DeformModifierSpec, DeformModifierTest
+from modules.mesh_test import MeshTest, ModifierSpec, OperatorSpecObjectMode, DeformModifierSpec, ModifierTest
tests = [
@@ -103,7 +103,7 @@ tests = [
]
-deform_tests = DeformModifierTest(tests)
+deform_tests = ModifierTest(tests)
command = list(sys.argv)
for i, cmd in enumerate(command):
if cmd == "--run-all-tests":
diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py
index ab7e73c384f..0d75a4f1c08 100644
--- a/tests/python/modules/mesh_test.py
+++ b/tests/python/modules/mesh_test.py
@@ -231,15 +231,6 @@ class MeshTest:
objects = bpy.data.objects
self.expected_object = objects[expected_object_name]
- def add_modifier_to_stack(self, modifier_spec: ModifierSpec):
- """
- Add a modifier to the operations stack.
- :param modifier_spec: modifier to add to the operations stack
- """
- self.operations_stack.append(modifier_spec)
- if self.verbose:
- print("Added modifier {}".format(modifier_spec))
-
def add_operator_to_stack(self, operator_spec: OperatorSpecEditMode):
"""
Adds an operator to the operations stack.
@@ -718,10 +709,40 @@ class OperatorTest:
raise Exception("Tests {} failed".format(self._failed_tests_list))
-class RunTest(ABC):
+class ModifierTest:
"""
- Inherited from Abstract Base Class, used by ModifierTest (Child Class)
+ Helper class that stores and executes modifier tests.
+
+ Example usage:
+
+ >>> modifier_list = [
+ >>> ModifierSpec("firstSUBSURF", "SUBSURF", {"quality": 5}),
+ >>> ModifierSpec("firstSOLIDIFY", "SOLIDIFY", {"thickness_clamp": 0.9, "thickness": 1})
+ >>> ]
+ >>> tests = [
+ >>> MeshTest("Test1", "testCube", "expectedCube", modifier_list),
+ >>> MeshTest("Test2", "testCube_2", "expectedCube_2", modifier_list)
+ >>> ]
+ >>> modifiers_test = ModifierTest(tests)
+ >>> modifiers_test.run_all_tests()
"""
+
+ def __init__(self, tests, apply_modifiers=False):
+ """
+ Construct a modifier test.
+ :param tests: list - list of modifier test cases. Each element in the list must contain the following
+ in the correct order:
+ 0) test_name: str - unique test name
+ 1) test_object_name: bpy.Types.Object - test object
+ 2) expected_object_name: bpy.Types.Object - expected object
+ 3) modifiers: list - list of mesh_test.ModifierSpec objects.
+ """
+ self.tests = tests
+ self._check_for_unique_test_name()
+ self.apply_modifiers = apply_modifiers
+ self.verbose = os.environ.get("BLENDER_VERBOSE") is not None
+ self._failed_tests_list = []
+
def _check_for_unique_test_name(self):
"""
Check if the test name is unique
@@ -767,48 +788,6 @@ class RunTest(ABC):
raise Exception("Tests {} failed".format(self._failed_tests_list))
- @abstractmethod
- def run_test(self, test_name: str):
- """
- For enforcing a check that any child class should have this method.
- """
- pass
-
-
-class ModifierTest(RunTest):
- """
- Helper class that stores and executes modifier tests.
-
- Example usage:
-
- >>> modifier_list = [
- >>> ModifierSpec("firstSUBSURF", "SUBSURF", {"quality": 5}),
- >>> ModifierSpec("firstSOLIDIFY", "SOLIDIFY", {"thickness_clamp": 0.9, "thickness": 1})
- >>> ]
- >>> tests = [
- >>> MeshTest("Test1", "testCube", "expectedCube", modifier_list),
- >>> MeshTest("Test2", "testCube_2", "expectedCube_2", modifier_list)
- >>> ]
- >>> modifiers_test = ModifierTest(tests)
- >>> modifiers_test.run_all_tests()
- """
-
- def __init__(self, tests, apply_modifiers=False):
- """
- Construct a modifier test.
- :param tests: list - list of modifier test cases. Each element in the list must contain the following
- in the correct order:
- 0) test_name: str - unique test name
- 1) test_object_name: bpy.Types.Object - test object
- 2) expected_object_name: bpy.Types.Object - expected object
- 3) modifiers: list - list of mesh_test.ModifierSpec objects.
- """
- self.tests = tests
- self._check_for_unique_test_name()
- self.apply_modifiers = apply_modifiers
- self.verbose = os.environ.get("BLENDER_VERBOSE") is not None
- self._failed_tests_list = []
-
def run_test(self, test_name: str):
"""
Run a single test from self.deform_tests list
More information about the Bf-blender-cvs
mailing list