Skip to content

Test suite fails with AttributeError if omicron is not installed #182

Description

@duncanmmacleod

The test suite for this project fails in a way that it shouldn't when omicron (the C++ exe) is not available:

___________________________________ test_from_channel_list_config ____________________________________

self = <omicron.parameters.OmicronParameters object at 0x7065affd0050>, version = None, defaults = {}
kwargs = {}

    def __init__(self, version=None, defaults=dict(), **kwargs):
        configparser.ConfigParser.__init__(self, defaults=defaults, **kwargs)
        if version is None:
            try:
>               version = utils.get_omicron_version()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

omicron/parameters.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
omicron/utils.py:101: in get_omicron_version
    executable = executable or find_omicron()
                               ^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def find_omicron():
        """Find the omicron executable in the environment

        Either via `PATH` or relative to the current python interpreter

        Returns
        -------
        path : `pathlib.Path`
            the path of the omicron executable

        Raises
        ------
        RuntimeError
            if omicron cannot be found, or is not executable
        """
        exe = which(
            "omicron",
            path=os.pathsep.join((
                os.getenv("PATH", ""),
                str(Path(sys.executable).parent),
            )),
        )
        if not exe or not os.access(exe, os.X_OK):
>           raise RuntimeError(
                "cannot locate omicron in environment or is not executable"
            )
E           RuntimeError: cannot locate omicron in environment or is not executable

omicron/utils.py:77: RuntimeError

During handling of the above exception, another exception occurred:

    def test_from_channel_list_config():
        # I disabled this test because the Omicron program segfaults when
        # it is run from pytest
        cp = ConfigParser()
        section = 'test'
        cp.add_section(section)
        cp.set(section, 'channels', 'X1:TEST-CHANNEL\nX1:TEST-CHANNEL_2')
        cp.set(section, 'flow', '10')
        cp.set(section, 'fhigh', '100')
        with tempfile.NamedTemporaryFile(suffix='.ini', mode='w') as f:
            cp.write(f)
>           pars = OmicronParameters.from_channel_list_config(cp, section)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

omicron/tests/test_parameters.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
omicron/parameters.py:212: in from_channel_list_config
    new = cls(version=version)
          ^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <omicron.parameters.OmicronParameters object at 0x7065affd0050>, version = None, defaults = {}
kwargs = {}

    def __init__(self, version=None, defaults=dict(), **kwargs):
        configparser.ConfigParser.__init__(self, defaults=defaults, **kwargs)
        if version is None:
            try:
                version = utils.get_omicron_version()
            except (KeyError, RuntimeError):
>               version = utils.OmicronVersion(const.OMICRON_VERSION)
                          ^^^^^^^^^^^^^^^^^^^^
E               AttributeError: module 'omicron.utils' has no attribute 'OmicronVersion'

omicron/parameters.py:69: AttributeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions