When I launch my code to gitlab it goes through the CI, but the pytest session fails while on local machine doesn't. On my gitlab-ci.yaml I tried installing pytest inside and outside the requirements.txt file, this is how it looks now:
.test:
tags: ["CsLib"]
before_script:
- python3 -m pip install -r requirements.txt
- python3 -m pip install pytest
pytest:
stage: test
extends: ".test"
script:
- nox -s test
After doing the installation it goes to the pytest defined session, that looks like this:
@session(python=["3.9"])
def test(s: Session) -> None:
s.posargs.append("--no-install")
s.run("python", "-m", "pytest", "tests", external=True)
I have enabled the use of existing virtualenvs, and typed external=True for it to use already installed packages. Yet it gives the error
$ nox -s test
nox > Running session test-3.9
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/test-3-9
nox > python -m pytest tests
/builds/RnD/python-libs/.nox/test-3-9/bin/python: No module named pytest
nox > Command python -m pytest tests failed with exit code 1
nox > Session test-3.9 failed.
The thing is, when doing a session lint that it has almost the same structure as the test session but using flake8 it gives no error.
@session(python=["3.9"])
def lint(s: Session) -> None:
s.posargs.append("--no-install")
s.run("flake8", external=True)
This 'flake8' is installed within the requirements file, I tried doing that with pytest but it does not work.
If I type 'nox -s test' in my local machine it executes it without any problem, so I must be doing something wrong on the CI part that I can not see.