Tests: Avoid access globals from abstract base class
Delegate functionality to subclasses, assert when subclasses didn't do job the are supposed to do. Thanks Sybren for pointing to a proper solution.
This commit is contained in:
@@ -58,11 +58,10 @@ def with_tempdir(wrapped):
|
|||||||
class AbstractBlenderRunnerTest(unittest.TestCase):
|
class AbstractBlenderRunnerTest(unittest.TestCase):
|
||||||
"""Base class for all test suites which needs to run Blender"""
|
"""Base class for all test suites which needs to run Blender"""
|
||||||
|
|
||||||
@classmethod
|
# Set in a subclass
|
||||||
def setUpClass(cls):
|
blender: pathlib.Path = None
|
||||||
global args
|
testdir: pathlib.Path = None
|
||||||
cls.blender = args.blender
|
|
||||||
cls.testdir = pathlib.Path(args.testdir)
|
|
||||||
|
|
||||||
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
|
def run_blender(self, filepath: str, python_script: str, timeout: int=300) -> str:
|
||||||
"""Runs Blender by opening a blendfile and executing a script.
|
"""Runs Blender by opening a blendfile and executing a script.
|
||||||
@@ -73,6 +72,9 @@ class AbstractBlenderRunnerTest(unittest.TestCase):
|
|||||||
:param timeout: in seconds
|
:param timeout: in seconds
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
assert self.blender, "Path to Blender binary is to be set in setUpClass()"
|
||||||
|
assert self.testdir, "Path to tests binary is to be set in setUpClass()"
|
||||||
|
|
||||||
blendfile = self.testdir / filepath
|
blendfile = self.testdir / filepath
|
||||||
|
|
||||||
command = (
|
command = (
|
||||||
|
Reference in New Issue
Block a user