From 528db620ed7464873ef8d679fd1e290e799252c6 Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Tue, 21 Feb 2023 21:21:15 +0100 Subject: [PATCH] Add automated test --- CHANGES.md | 13 +++++++++---- pylint_venv.py | 4 ++-- test/empty.py | 0 test/pylintrc | 4 ++++ test/test.sh | 12 ++++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 test/empty.py create mode 100644 test/pylintrc create mode 100755 test/test.sh diff --git a/CHANGES.md b/CHANGES.md index cd9f2a2..b18a592 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,16 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [3.0.0] - unreleased +### Changed + +- Require that the `force_venv_activation` argument to `inithook` is passed + as keyword argument. + +### Removed + +- Remove (official) support for Python 3.6. + ### Fixed - Do not include documentation files in pure library distribution ([#13](https://github.com/jgosmann/pylint-venv/pull/13)). - Clarify that the hook has to be configured in the `[MAIN]` section ([#14](https://github.com/jgosmann/pylint-venv/pull/14)) - -### Removed - -- Remove (official) support for Python 3.6. ## [2.3.0] - 2022-06-24 diff --git a/pylint_venv.py b/pylint_venv.py index c05f985..ff4fb32 100644 --- a/pylint_venv.py +++ b/pylint_venv.py @@ -108,7 +108,7 @@ def activate_venv(venv): sys.path[:] = new_paths + kept_paths -def inithook(venv=None, force_venv_activation=False, *, quiet=False): +def inithook(venv=None, *, force_venv_activation=False, quiet=False): """Add virtualenv's paths and site_packages to Pylint. Use environment with prefix *venv* if provided else try to auto-detect an active virtualenv. @@ -127,5 +127,5 @@ def inithook(venv=None, force_venv_activation=False, *, quiet=False): return if not quiet: - print(f"Using env: {venv}", file=sys.stderr) + print(f"Using venv: {venv}", file=sys.stderr) activate_venv(venv) diff --git a/test/empty.py b/test/empty.py new file mode 100644 index 0000000..e69de29 diff --git a/test/pylintrc b/test/pylintrc new file mode 100644 index 0000000..df26565 --- /dev/null +++ b/test/pylintrc @@ -0,0 +1,4 @@ +[MAIN] +init-hook= + import pylint_venv + pylint_venv.inithook(force_venv_activation=True) diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..351b2c9 --- /dev/null +++ b/test/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -o errexit -o nounset -o pipefail -o xtrace + +WORKDIR=$(dirname "$0") +PYLINT_CMD=$(which pylint) +VENV_DIR=$(mktemp -d) + +python3 -m venv "$VENV_DIR" +source "$VENV_DIR/bin/activate" +"$PYLINT_CMD" --rcfile "$WORKDIR/pylintrc" "$WORKDIR/empty.py" 2>&1 | tee "$VENV_DIR/pylint.log" | grep "^Using venv: $VENV_DIR\$" +rm -r "$VENV_DIR"