tarpas / pytest-testmon

Selects tests affected by changed files. Executes the right tests first. Continuous test runner when used with pytest-watch.
https://testmon.org
MIT License
800 stars 54 forks source link

fails when git is not present #214

Closed meshantz closed 1 year ago

meshantz commented 1 year ago

In development, I typically run tests inside a container that does not have git present. v2 breaks this workflow, because it assumes git is present from the looks of things.

I don't think any of the extra extensions relate to this problem, but I'm happy to narrow this down if reproducing it turns out to not be straightforward.

What is your setup and what steps did you do? mount code into a container and attempt to run pytest with testmon.

$ pip freeze | grep pytest
pytest==7.2.2
pytest-asyncio==0.21.0
pytest-cov==4.0.0
pytest-socket==0.6.0
pytest-testmon==2.0.5
pytest-watch==4.2.0

What was the outcome? Big nasty traceback with pytest error code 3.

pytest --testmon --asyncio-mode=auto -m "not testdb"
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 266, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1039, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 277, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/testmon/pytest_testmon.py", line 228, in pytest_configure
INTERNALERROR>     init_testmon_data(config)
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/testmon/pytest_testmon.py", line 166, in init_testmon_data
INTERNALERROR>     testmon_data = TestmonData(
INTERNALERROR>   File "/usr/local/lib/python3.10/site-packages/testmon/testmon_core.py", line 160, in __init__
INTERNALERROR>     check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()
INTERNALERROR>   File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output
INTERNALERROR>     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
INTERNALERROR>   File "/usr/local/lib/python3.10/subprocess.py", line 501, in run
INTERNALERROR>     with Popen(*popenargs, **kwargs) as process:
INTERNALERROR>   File "/usr/local/lib/python3.10/subprocess.py", line 966, in __init__
INTERNALERROR>     self._execute_child(args, executable, preexec_fn, close_fds,
INTERNALERROR>   File "/usr/local/lib/python3.10/subprocess.py", line 1842, in _execute_child
INTERNALERROR>     raise child_exception_type(errno_num, err_msg, err_filename)
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory: 'git'

$ echo $?
3

What did you expect instead? Happy test run.

What is your operating system and it's version please? Container running Debian 11 (bullseye) under windows (docker desktop, WSL2). Kernel version 4.19.104-microsoft-standard

pokopt commented 1 year ago

Hi @meshantz! Thank you for reporting and sorry for inconvenience. Please check the latest testmon version (2.0.6) with fix.

meshantz commented 1 year ago

Seems to work. Thanks for the quick action!