Skip to content

chore(tests): port the Makefile test targets to pytest - #445

Merged
ekalinin merged 1 commit into
masterfrom
chore/makefile-tests-to-pytest
Oct 25, 2026
Merged

ekalinin merged 1 commit into
masterfrom
chore/makefile-tests-to-pytest

Conversation

@ekalinin

Copy link
Copy Markdown
Owner

Closes #444

What happens

make tests builds real environments, but CI never runs it, and only test1 has a pytest counterpart (test_smoke). Two targets no longer check what they describe:

  • test7 compares wc -l with " 1", the padded output of BSD wc. GNU wc prints 1, so the target fails on Linux.
  • In test10 the second run finds the same node installed and skips install_node, so it never reaches the Symlink to env/bbin/npm fails if npm already exists #189 branch of copytree.

What changes

The cases become integration tests in tests/nodeenv_test.py, which the ubuntu integration job already runs:

Target Test
test2, test3 test_smoke_python_virtualenv: nodeenv -p in a real virtualenv. One test, since -j 4 has no effect with --prebuilt
test4 test_smoke_python_virtualenv_n_system: -p --node=system, on the job's Python instead of 3.9
test7 test_smoke_python_virtualenv_freeze: npm install -g sitemap, then freeze prints exactly one sitemap@ line, checked in Python instead of with wc
test8, test9 test_smoke_special_dir_names[unicode,space]: --prebuilt into öäü/env and test dir/env
test10 test_smoke_python_virtualenv_twice: the second run uses --force, so it copies node over the links the first one left
  • The -p tests create a stdlib venv and run nodeenv -p with VIRTUAL_ENV and PATH set as activation sets them, so -p finds the virtualenv the way it did in the Makefile. VIRTUAL_ENV is always replaced: run from an activated dev venv, nodeenv would install node there otherwise.
  • Each test sources the resulting bin/activate and checks where node, npm and npx resolve, as test_smoke does.
  • test_copytree_keeps_existing_symlink covers the Symlink to env/bbin/npm fails if npm already exists #189 branch of copytree in the whole tox matrix, not only in the integration job.
  • test5 (python2.7) is dropped: without the interpreter it is the same run as test2. Python 2.7 itself is setup.py still declares Python 2.7 support #436.
  • test1..test10, tests, SETUP and the rm -rf nodeenv/ that only cleaned up after test1 are removed from the Makefile.

Tests

Each new check was seen failing with the code it guards removed from nodeenv.py:

The freeze test doesn't catch a missing --depth=0: npm 11 lists only top-level packages without --all anyway.

All 21 jobs of the branch push are green. The integration job runs the 6 new test ids in about 25 seconds.

`make tests` built real environments, but CI never ran it, and only
test1 had a pytest counterpart (test_smoke). The other cases become
integration tests, run by the ubuntu integration job:

- test2, test3: `nodeenv -p` in a real virtualenv (one test, -j 4 has
  no effect with --prebuilt)
- test4: `-p --node=system`, on the job's Python instead of 3.9
- test7: `freeze` after `npm install -g sitemap`, checked in Python
  instead of comparing with the padded output of BSD wc, which failed
  on Linux
- test8, test9: --prebuilt into `öäü` and `test dir`
- test10: the second run now uses --force; without it the installed
  node is skipped and the #189 branch of copytree is never reached

A unit test covers that branch of copytree in the whole tox matrix.
test5 (python2.7) is dropped: without the interpreter it is test2.

The targets, `tests`, SETUP and the `rm -rf nodeenv/` that only cleaned
up after test1 are removed from the Makefile.

Closes #444
@ekalinin
ekalinin merged commit eb7c627 into master Oct 25, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move the Makefile test targets to pytest

1 participant