Skip to content

Commit

Permalink
Added auto_save_result wrapper to save results from test cases to che…
Browse files Browse the repository at this point in the history
…ck the files in Maya so I don't have to restart Maya every time.
  • Loading branch information
AndresMWeber committed Mar 9, 2018
1 parent 43a30ed commit bc0650c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/acceptance/test_biped.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import anvil.config as cfg
import anvil.node_types as nt
from anvil.rig_templates import Biped
from tests.base_test import TestBase, sanitize
from tests.base_test import TestBase, sanitize, auto_save_result


class TestBaseTemplateRigs(TestBase):
Expand All @@ -11,6 +11,7 @@ class TestBaseTemplateRigs(TestBase):
CLASS = Biped

@classmethod
@auto_save_result
def from_template_file(cls, template_file, **kwargs):
cls.import_template_files(template_file)

Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/test_hand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import anvil.node_types as nt
from anvil.utils.scene import print_scene_tree
from anvil.sub_rig_templates import Hand
from tests.base_test import TestBase, clean_up_scene
from tests.base_test import TestBase, clean_up_scene, auto_save_result
import string
from pprint import pprint

Expand All @@ -14,6 +14,7 @@ class TestHandBase(TestBase):
TEMPLATE_CLASS = Hand

@classmethod
@auto_save_result
def from_template_file(cls, template_file, finger_start_joints=None, **kwargs):
cls.import_template_files(template_file)

Expand Down
16 changes: 16 additions & 0 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from contextlib import contextmanager
import nomenclate
import anvil
import anvil.runtime as rt
from anvil.log import obtain_logger

NOMENCLATE = nomenclate.Nom()
Expand Down Expand Up @@ -102,3 +103,18 @@ def wrapped(self, *args, **kwargs):
return func_return

return wrapped

def auto_save_result(func):
@wraps(func)
def wrapped(self, *args, **kwargs):
save_file = kwargs.pop('save_file', False)
save_path = kwargs.pop('save_path', False)
func_return = func(self, *args, **kwargs)
if save_file:
rt.dcc.scene.fileop(rename=os.path.join([f for f in [save_path, save_file, 'mb'] if f]),
save=True,
type='mayaBinary')
return func_return

return wrapped

0 comments on commit bc0650c

Please sign in to comment.