How to use the anypytools.macro_commands function in anypytools

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
for k, v in self.config.getoption("define_kw") or {}:
            self.defs[k] = v
        self.defs["TEST_NAME"] = '"{}"'.format(test_name)
        if self.config.getoption("--ammr"):
            paths["AMMR_PATH"] = self.config.getoption("--ammr")
            paths["ANYBODY_PATH_AMMR"] = self.config.getoption("--ammr")
        self.paths = _as_absolute_paths(paths, start=self.config.rootdir.strpath)
        self.name = test_name
        self.expect_errors = kwargs.get("expect_errors", [])

        for marker in kwargs.get("pytest_markers", []):
            self.add_marker(marker)

        self.timeout = self.config.getoption("--timeout")
        self.errors = []
        self.macro = [macro_commands.Load(self.fspath.strpath, self.defs, self.paths)]

        fatal_warnings = kwargs.get("fatal_warnings", False)
        warnings_to_include = kwargs.get("warnings_to_include", None)
        if warnings_to_include:
            warnings.warn(
                f"\n{name}:`warnings_to_include` is deprecated. \nSpecify the `fatal_warnings` variable as "
                "a list to select specific warnings",
                DeprecationWarning,
            )
            if not isinstance(fatal_warnings, collections.abc.Sequence):
                fatal_warnings = warnings_to_include

        if not isinstance(fatal_warnings, collections.abc.Sequence):
            fatal_warnings = ["WARNING"] if fatal_warnings else []

        self.app_opts = {
github AnyBody-Research-Group / AnyPyTools / anypytools / pytest_plugin.py View on Github external
fatal_warnings = ["WARNING"] if fatal_warnings else []

        self.app_opts = {
            "silent": True,
            "debug_mode": self.config.getoption("--anybody_debug_mode"),
            "anybodycon_path": pytest.anytest.ams_path,
            "timeout": self.timeout,
            "ignore_errors": kwargs.get("ignore_errors", []),
            "warnings_to_include": fatal_warnings,
            "fatal_warnings": bool(fatal_warnings),
            "keep_logfiles": kwargs.get("keep_logfiles", True),
            "logfile_prefix": kwargs.get("logfile_prefix", None),
            "use_gui": kwargs.get("use_gui", False),
        }
        if not self.config.getoption("--only-load"):
            self.macro.append(macro_commands.OperationRun("Main.RunTest"))

        self.hdf5_outputs = []
        save_study = kwargs.get("save_study", None)
        if self.config.getoption("--anytest-output") and save_study:
            save_study = [save_study] if isinstance(save_study, str) else save_study
            for study in save_study:
                fname = f"{study}.anydata.h5"
                self.macro.append(
                    f'classoperation {study}.Output "Save data" --type="Deep" --file="{fname}"'
                )
                self.hdf5_outputs.append(fname)
        return
github AnyBody-Research-Group / AnyPyTools / tests / test_macros.py View on Github external
def test_savedata():
    c = mc.SaveData('Main.MyStudy', 'output.anydata.h5')
    assert c.get_macro(0) == 'classoperation Main.MyStudy.Output "Save data" --type="Deep" --file="output.anydata.h5"'
github AnyBody-Research-Group / AnyPyTools / tests / test_macros.py View on Github external
def test_load():
    cmd = mc.Load('main.any', defs =  {'TEST_STR': '"Test\\string"'} )
    assert cmd.get_macro(0) == 'load "main.any" -def TEST_STR=---"\\"Test\\\\string\\""'

    cmd = mc.Load('main.any', defs =  {'TEST_VAR': 'Main.MyStudy'} )
    assert cmd.get_macro(0) == 'load "main.any" -def TEST_VAR="Main.MyStudy"' 

    cmd = mc.Load('main.any', paths = {'TEST_PATH': 'c:\\path\\to\\something' })
    assert cmd.get_macro(0) == 'load "main.any" -p TEST_PATH=---"c:\\\\path\\\\to\\\\something"'