class IntentTestSequence(unittest.TestCase): __metaclass__ = IntentTestSequenceMeta @classmethod def setUpClass(self): self.loader = MockSkillsLoader(SKILL_PATH) self.emitter = self.loader.load_skills() @classmethod def tearDownClass(self): self.loader.unload_skills()
if len(test_intent_files) > 0: tests[skill] = test_intent_files return tests def get_skills_dir(): return (expanduser(os.environ.get('SKILLS_DIR', '')) or expanduser( join(Configuration.get()['data_dir'], Configuration.get()['skills']['msm']['directory']))) skills_dir = get_skills_dir() tests = discover_tests(skills_dir) loader = MockSkillsLoader(skills_dir) emitter = loader.load_skills() skill_dir = os.environ.get('SKILL_DIR', '') class TestCase(object): @pytest.mark.parametrize( "skill,test", sum([[(skill, test) for test in tests[skill]] for skill in tests.keys() if not skill_dir or abspath(skill).startswith(abspath(skill_dir)) ], [])) def test_skill(self, skill, test): example, test_env = test if test_env: assert test_env.test_runner(skill, example, emitter, loader) else:
""" Run test_setup for all loaded skills. """ for s in loader.skills: if len(tests.get(s.root_dir, [])) > 0: try: test_env = tests[s.root_dir][0] if hasattr(test_env[1], 'test_setup'): print('Running test setup for {}'.format(s.name)) test_env[1].test_setup(s) except Exception as e: print('test_setup for {} failed: {}'.format(s.name, repr(e))) skills_dir = get_skills_dir() tests = discover_tests(skills_dir) loader = MockSkillsLoader(skills_dir) emitter = loader.load_skills() skill_dir = os.environ.get('SKILL_DIR', '') run_test_setup(loader, tests) class TestCase(object): @pytest.mark.parametrize("skill,test", sum([ [(skill, test) for test in tests[skill]] for skill in tests.keys() if not skill_dir or abspath(skill).startswith(abspath(skill_dir)) ], [])) def test_skill(self, skill, test): example, test_env = test if test_env and hasattr(test_env, 'test_runner'): assert test_env.test_runner(skill, example, emitter, loader) else: