Skip to content

Commit

Permalink
Add automated test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosmann committed Feb 21, 2023
1 parent 9b9d15c commit 528db62
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
13 changes: 9 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pylint_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Empty file added test/empty.py
Empty file.
4 changes: 4 additions & 0 deletions test/pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[MAIN]
init-hook=
import pylint_venv
pylint_venv.inithook(force_venv_activation=True)
12 changes: 12 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 528db62

Please sign in to comment.