Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for build environment relying on PYTHONPATH #318

Merged
merged 1 commit into from Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fixed tests for build environments relying on `PYTHONPATH` (#318 by [@befeleme]).

## [0.17.0] - 2021-04-02

### Changed
Expand Down Expand Up @@ -232,6 +238,7 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[@andrewsmith]: https://github.com/andrewsmith
[@asyncee]: https://github.com/asyncee
[@bbc2]: https://github.com/bbc2
[@befeleme]: https://github.com/befeleme
[@cjauvin]: https://github.com/cjauvin
[@earlbread]: https://github.com/earlbread
[@ekohl]: https://github.com/ekohl
Expand Down
16 changes: 8 additions & 8 deletions tests/test_cli.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import os

import pytest
import sh

Expand Down Expand Up @@ -143,8 +145,10 @@ def test_run_with_existing_variable(tmp_path):
dotenv_file = str(tmp_path / ".env")
with open(dotenv_file, "w") as f:
f.write("a=b")
env = dict(os.environ)
env.update({"LANG": "en_US.UTF-8", "a": "c"})

result = sh.dotenv("run", "printenv", "a", _env={"LANG": "en_US.UTF-8", "a": "c"})
result = sh.dotenv("run", "printenv", "a", _env=env)

assert result == "b\n"

Expand All @@ -154,14 +158,10 @@ def test_run_with_existing_variable_not_overridden(tmp_path):
dotenv_file = str(tmp_path / ".env")
with open(dotenv_file, "w") as f:
f.write("a=b")
env = dict(os.environ)
env.update({"LANG": "en_US.UTF-8", "a": "c"})

result = sh.dotenv(
"run",
"--no-override",
"printenv",
"a",
_env={"LANG": "en_US.UTF-8", "a": "c"},
)
result = sh.dotenv("run", "--no-override", "printenv", "a", _env=env)

assert result == "c\n"

Expand Down