def test_invalid_type(self): """Test that a condition which is not callable raises an exception.""" m = Mach(os.getcwd()) m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10) self.assertRaises(MachError, m.load_commands_from_file, os.path.join(self.provider_dir, 'conditions_invalid.py'))
def main(args): m = Mach(os.getcwd()) m.define_category('docker', 'Docker', 'Common actions involving Docker') import vcttesting.docker_mach_commands return m.run(args)
def _run_mach(self, args, provider_file=None, entry_point=None, context_handler=None): m = Mach(os.getcwd()) m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10) m.populate_context_handler = context_handler if provider_file: m.load_commands_from_file( os.path.join(self.provider_dir, provider_file)) if entry_point: m.load_commands_from_entry_point(entry_point) stdout = StringIO() stderr = StringIO() stdout.encoding = 'UTF-8' stderr.encoding = 'UTF-8' try: result = m.run(args, stdout=stdout, stderr=stderr) except SystemExit: result = None return (result, stdout.getvalue(), stderr.getvalue())
def test_invalid_type(self): """Test that a condition which is not callable raises an exception.""" m = Mach(os.getcwd()) m.define_category("testing", "Mach unittest", "Testing for mach core", 10) self.assertRaises( MachError, m.load_commands_from_file, os.path.join(PROVIDER_DIR, "conditions_invalid.py"), )
def get_mach(self, provider_file=None, entry_point=None, context_handler=None): m = Mach(os.getcwd()) m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10) m.populate_context_handler = context_handler if provider_file: m.load_commands_from_file(os.path.join(self.provider_dir, provider_file)) if entry_point: m.load_commands_from_entry_point(entry_point) return m
def inner(provider_files=None, entry_point=None, context_handler=None): m = Mach(os.getcwd()) m.define_category("testing", "Mach unittest", "Testing for mach core", 10) m.define_category("misc", "Mach misc", "Testing for mach core", 20) m.populate_context_handler = context_handler or _populate_context if provider_files: if isinstance(provider_files, six.string_types): provider_files = [provider_files] for path in provider_files: m.load_commands_from_file(os.path.join(PROVIDER_DIR, path)) if entry_point: m.load_commands_from_entry_point(entry_point) return m
def get_mach(cls, provider_files=None, entry_point=None, context_handler=None): m = Mach(os.getcwd()) m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10) m.define_category('misc', 'Mach misc', 'Testing for mach core', 20) m.populate_context_handler = context_handler if provider_files: if isinstance(provider_files, six.string_types): provider_files = [provider_files] for path in provider_files: m.load_commands_from_file(os.path.join(cls.provider_dir, path)) if entry_point: m.load_commands_from_entry_point(entry_point) return m
def _run_mach(self, args, provider_file=None, entry_point=None, context_handler=None): m = Mach(os.getcwd()) m.define_category('testing', 'Mach unittest', 'Testing for mach core', 10) m.populate_context_handler = context_handler if provider_file: m.load_commands_from_file(os.path.join(self.provider_dir, provider_file)) if entry_point: m.load_commands_from_entry_point(entry_point) stdout = StringIO() stderr = StringIO() stdout.encoding = 'UTF-8' stderr.encoding = 'UTF-8' try: result = m.run(args, stdout=stdout, stderr=stderr) except SystemExit: result = None return (result, stdout.getvalue(), stderr.getvalue())