Skip to content

Commit

Permalink
Fix issues with environment test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Aug 18, 2024
1 parent b73a6e1 commit 04a98d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/test_hooks/test_run_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess

Check warning on line 1 in tests/test_hooks/test_run_command.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/test_hooks/test_run_command.py#L1

Consider possible security implications associated with the subprocess module.
import sys

import pytest

Expand All @@ -16,7 +17,8 @@ def test_runs_a_str_command(self):

def test_can_access_env(self):
"""The command can access custom environment variables."""
result = run_command("echo $TEST_ENV", environment={"TEST_ENV": "Hello"})
cmd = "echo %TEST_ENV%" if sys.platform == "win32" else "echo $TEST_ENV"
result = run_command(cmd, environment={"TEST_ENV": "Hello"})
assert isinstance(result, subprocess.CompletedProcess)
assert result.stdout == "Hello\n"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pytest
from pytest import param
from bumpversion.hooks import run_setup_hooks, run_pre_commit_hooks, run_post_commit_hooks
from bumpversion.versioning.models import Version
from tests.conftest import get_config_data, get_semver


Expand Down

0 comments on commit 04a98d0

Please sign in to comment.