Skip to content

Commit

Permalink
Don't write bytecode when invoking Python tests (#611)
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 authored Feb 2, 2024
1 parent 291f16c commit 6529b6b
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'
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 6529b6b

Please sign in to comment.