How to use anypytools - 10 common examples

To help you get started, we’ve selected a few anypytools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AnyBody-Research-Group / AnyPyTools / anypytools / pytest_plugin.py View on Github external
def runtest(self):
        """Run an AnyScript test item."""

        tmpdir = Path(
            TempdirFactory(TempPathFactory.from_config(self.config)).mktemp(self.name)
        )

        with change_dir(tmpdir):
            self.app = AnyPyProcess(**self.app_opts)
            result = self.app.start_macro(self.macro)[0]

        # Ignore error due to missing Main.RunTest
        if "ERROR" in result:
            runtest_missing = any(
                "Error : Main.RunTest :" in err for err in result["ERROR"]
            )
            if runtest_missing:
                runtest_errros = (
                    "Error : Main.RunTest : Unresolved",
                    "Main.RunTest : Select Operation",
                    "Error : run : command unexpected while",
                )
                result["ERROR"][:] = [
                    err
                    for err in result["ERROR"]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_explicit_logfiles_multiple(self, init_simple_model):
        logfile = "test.log"
        macro = [
            ['load "model.main.any"', "operation Main.ArmModelStudy.InverseDynamics"],
            ['load "model.main.any"', "operation Main.ArmModelStudy.InverseDynamics"],
            ['load "model.main.any"', "operation Main.ArmModelStudy.InverseDynamics"],
        ]
        app = AnyPyProcess(silent=True, keep_logfiles=True)
        output = app.start_macro(macro, logfile=logfile)
        assert os.path.isfile("test_0.log")
        assert os.path.isfile("test_1.log")
        assert os.path.isfile("test_2.log")
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_with_gui(self, init_simple_model, default_macro):
        app = AnyPyProcess(silent=True, use_gui=False)
        default_macro[0].append("run")
        output = app.start_macro(default_macro)
        assert not "ERROR" in output[0]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_start_macro_generator_input(self, init_simple_model, default_macro):
        n_macros = 5

        def generate_macros():
            """Generator that returns macros
            """
            for i in range(n_macros):
                yield default_macro[0]

        app = AnyPyProcess(silent=True)
        macros_gen = generate_macros()
        output = app.start_macro(macros_gen)

        assert len(output) == n_macros
        for result in output:
            assert "ERROR" not in result
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
macro = [
            [
                'load "model.main.any" -def N_STEP="10"',
                "operation Main.ArmModelStudy.InverseDynamics",
                'classoperation Main.ArmModelStudy.Output.MaxMuscleActivity "Dump"',
                'classoperation Main.ArmModel.GlobalRef.t "Dump"',
            ],
            [
                'load "model.main.any" -def N_STEP="20"',
                "operation Main.ArmModelStudy.InverseDynamics",
                'classoperation Main.ArmModelStudy.Output.MaxMuscleActivity "Dump"',
                'classoperation Main.ArmModel.GlobalRef.t "Dump"',
            ],
        ]

        app = AnyPyProcess()
        output = app.start_macro(macro)
        output["GlobalRef.t"]
        output["MaxMuscleActivity"]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_start_macro(self, init_simple_model, default_macro):
        app = AnyPyProcess(silent=True)

        default_macro[0].extend(
            [
                'classoperation Main.ArmModelStudy.Output.MaxMuscleActivity "Dump"',
                'classoperation Main.ArmModel.GlobalRef.t "Dump"',
            ]
        )

        output = app.start_macro(default_macro)

        assert len(output) == 1
        assert "Main.ArmModelStudy.Output.MaxMuscleActivity" in output[0]
        assert "Main.ArmModel.GlobalRef.t" in output[0]
        assert "ERROR" not in output[0]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_logfile_persistance(self, init_simple_model, default_macro):
        app = AnyPyProcess(silent=True, keep_logfiles=True)
        output = app.start_macro(default_macro)
        assert os.path.isfile(output[0]["task_logfile"])
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_start_macro_with_task_info(self, init_simple_model, default_macro):
        app = AnyPyProcess(silent=True)

        default_macro[0].extend(
            [
                'classoperation Main.ArmModelStudy.Output.MaxMuscleActivity "Dump"',
                'classoperation Main.ArmModel.GlobalRef.t "Dump"',
            ]
        )

        output = app.start_macro(default_macro)

        assert len(output) == 1
        assert "task_macro_hash" in output[0]
        assert "task_id" in output[0]
        assert "task_work_dir" in output[0]
        assert "task_name" in output[0]
        assert "task_processtime" in output[0]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_macro_with_erros(self, init_simple_model, default_macro):
        app = AnyPyProcess(
            silent=True, ignore_errors=["Unresolved object"]
        )
        macro = [
            ['load "model.main.any"', "operation Main.ArmModelStudy.InverseDynamics"],
            ['load "model.main.any"', "operation Main.NonExistentOpeation"],
            ['load "not_a_model.any"', "operation Main.ArmModelStudy.InverseDynamics"],
        ]

        output = app.start_macro(macro)

        assert not "ERROR" in output[0]
        assert not "ERROR" in output[1]
        assert "ERROR" in output[2]
github AnyBody-Research-Group / AnyPyTools / tests / test_abcutils.py View on Github external
def test_explicit_logfiles_path(self, init_simple_model, default_macro):
        logfile = pathlib.Path("test.log")
        app = AnyPyProcess(silent=True, keep_logfiles=True)
        output = app.start_macro(default_macro, logfile=logfile)
        assert os.path.isfile(logfile)