Skip to content

Run tests via meson #159

@jelly

Description

@jelly

Currently the tests seem to require pip install . which I rather avoid on a machine. I tried running the tests by messing with PYTHONPATH but this is impossible as the C extension modules end up in build with an underscore and not all of them use a wrapper ie:

[jelle@carbon][~/projects/python-systemd]%PYTHONPATH=src:build/src/systemd pytest
===================================================================================== test session starts ======================================================================================
platform linux -- Python 3.13.7, pytest-8.4.2, pluggy-1.6.0
rootdir: /home/jelle/projects/python-systemd
configfile: pyproject.toml
plugins: cov-6.1.1, asyncio-0.26.0
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 2 items / 10 errors

============================================================================================ ERRORS ============================================================================================
____________________________________________________________________________ ERROR collecting src/systemd/daemon.py ____________________________________________________________________________
ImportError while importing test module '/home/jelle/projects/python-systemd/src/systemd/daemon.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/systemd/daemon.py:5: in <module>
    from ._daemon import (__version__,
E   ModuleNotFoundError: No module named 'systemd._daemon'

Doesn't work, so alternatively maybe the pip install can happen in a virtualenv but with system packages? Either way meson supports a custom test target which seems to be useful for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions