Skip to content

Commit

Permalink
Remove Python 2-specific code in nox/command.py (#203)
Browse files Browse the repository at this point in the history
* Remove python2 code

* Fix typo

* Remove test

This test isn't longer valid,
we always expect a python unicode string
  • Loading branch information
stsewd authored and theacodes committed Jun 2, 2019
1 parent 723544f commit 7125473
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
9 changes: 2 additions & 7 deletions nox/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def which(program, path):


def _clean_env(env):
# Environment variables must be unicode strings on Python 2.
if env is None:
return None

Expand All @@ -58,11 +57,7 @@ def _clean_env(env):
# Ensure systemroot is passed down, otherwise Windows will explode.
clean_env["SYSTEMROOT"] = os.environ.get("SYSTEMROOT", "")

for key, value in env.items():
key = key.decode("utf-8") if isinstance(key, bytes) else key
value = value.decode("utf-8") if isinstance(value, bytes) else value
clean_env[key] = value

clean_env.update(env)
return clean_env


Expand Down Expand Up @@ -101,7 +96,7 @@ def run(
raise CommandFailed("External program disallowed.")
elif external is False:
logger.warning(
"Warning: {} is not installed into the virtualenv, is it located at {}. This might cause issues! "
"Warning: {} is not installed into the virtualenv, it is located at {}. This might cause issues! "
"Pass external=True into run() to silence this message.".format(
cmd, cmd_path
)
Expand Down
10 changes: 0 additions & 10 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ def test_run_silent(capsys):
assert out == ""


def test_run_env_binary():
result = nox.command.run(
[PYTHON, "-c", 'import os; print(os.environ.get("SIGIL"))'],
silent=True,
env={b"SIGIL": b"123"},
)

assert "123" in result


def test_run_env_unicode():
result = nox.command.run(
[PYTHON, "-c", 'import os; print(os.environ["SIGIL"])'],
Expand Down

0 comments on commit 7125473

Please sign in to comment.