Skip to content

Commit

Permalink
Don't write bytecode when invoking Python tests
Browse files Browse the repository at this point in the history
This should help to avoid writing compiled bytecode into the source
directories of Python packages during test invocation.
  • Loading branch information
cottsay committed Feb 2, 2024
1 parent 291f16c commit 6cb4447
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions colcon_core/task/python/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ async def test(self, *, additional_hooks=None): # noqa: D102

logger.log(1, f"test.step() by extension '{key}'")
try:
if 'PYTHONDONTWRITEBYTECODE' not in env:
env = dict(env)
env['PYTHONDONTWRITEBYTECODE'] = '1'

Check warning on line 78 in colcon_core/task/python/test/__init__.py

View check run for this annotation

Codecov / codecov/patch

colcon_core/task/python/test/__init__.py#L77-L78

Added lines #L77 - L78 were not covered by tests
return await extension.step(self.context, env, setup_py_data)
except Exception as e: # noqa: F841
# catch exceptions raised in python testing step extension
Expand Down
1 change: 1 addition & 0 deletions test/spell_check.words
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ purelib
pydocstyle
pytest
pytests
pythondontwritebytecode
pythonpath
pythonscriptspath
pythonwarnings
Expand Down

0 comments on commit 6cb4447

Please sign in to comment.