Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving tests to tox #222

Open
fsimonis opened this issue Sep 4, 2024 · 1 comment
Open

Moving tests to tox #222

fsimonis opened this issue Sep 4, 2024 · 1 comment
Assignees

Comments

@fsimonis
Copy link
Member

fsimonis commented Sep 4, 2024

In tox, one can run disable the automatic installation of the package and run custom commands to setup an environment.

This should allow us to build the mock locally, then install the bindings and test against them.

https://tox.wiki/en/latest/config.html#skip_install

https://tox.wiki/en/latest/config.html#commands

We may need to LD_PRELOAD the mock though.

@BenjaminRodenberg
Copy link
Member

BenjaminRodenberg commented Mar 11, 2025

As far as I understand this we could have two different setup.py files in tox and we just pick the right one depending on whether we want to test or not. I would suggest the following structure:

python-bindings
├──setup.py
└── test
    └──setup.py

With tox we should be able to setup something along the following lines:

[tox]
envlist = py38, py39, py310

[testenv]
# Define dependencies common for both building and testing
deps =
    cython
    setuptools
    pytest

# Commands for building and installing the library using the main setup.py, 
# and then running tests using 'test/setup.py'
commands =
    # Build and install the library from the root 'python-bindings/setup.py'
    python setup.py install
    # Run tests from the 'test' directory using 'test/setup.py'
    pytest test --setup=python-bindings/test/setup.py

(tox.ini proposed by ChatGPT so I defintely need to understand it better and verify that it actually works. But I think it should suffice to sketch the idea.) There is no option pytest test --setup=..., it looks like there are some workarounds to use different setup.py files but at the moment these solutions look to me very complicated and introduce a lot of code duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants