Unable to Run Pytest in Dev Env
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
After spinning up the Docker envt using `start-build-env.sh` and following the instructions to create a virtual environment for python testing [here](https://cwiki.apache.org/confluence/display/BEAM/Python+Tips), I repeatedly received the error `ImportError: cannot import name 'console_main'` when trying to run pytest. This seems to be due to the pytest version or Dockerfile setup, unclear (see [this pytest issue](https://github.com/pytest-dev/pytest/issues/7650) or [this thread](https://github.com/web-platform-tests/wpt/issues/24880) for similar examples).
Changing `console_main` to `main` in `/usr/local/bin/pytest` as below, i.e. from
```
import re
import sys
from pytest import main
if __name__ == '__console_main__':
sys.argv[0]
= re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(console_main())
```
to the following
```
import re
import sys
from pytest import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$',
'', sys.argv[0])
sys.exit(main())
```
allowed me to run pytest within my environment without issue.
Imported from Jira [BEAM-12568](https://issues.apache.org/jira/browse/BEAM-12568). Original Jira may contain additional context.
Reported by: heidi_pachama.
Contributor guide
Assessment
This issue has not been assessed yet.