Skip to content

Commit

Permalink
General fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat committed Jul 27, 2020
1 parent c91a77a commit 4ec1dce
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/tox/config/source/ini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _load_raw_from(self, as_name, conf, key):
if self._section is None:
raise KeyError(key)
value = self._section[key]
collapsed_newlines = value.replace("\\\n", "") # collapse explicit line splits
collapsed_newlines = value.replace("\\\r", "").replace("\\\n", "") # collapse explicit line splits
replace_executed = replace(collapsed_newlines, conf, as_name, self._section_loader) # do replacements
factor_selected = filter_for_env(replace_executed, as_name) # select matching factors
# extend factors
Expand Down
1 change: 1 addition & 0 deletions src/tox/config/source/ini/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def to_path(value):
@staticmethod
def to_list(value):
splitter = "\n" if "\n" in value else ","
splitter = splitter.replace("\r", "")
for token in value.split(splitter):
value = token.strip()
if value:
Expand Down
Empty file removed src/tox/execute/outcome.py
Empty file.
13 changes: 12 additions & 1 deletion src/tox/pytest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import textwrap
from contextlib import contextmanager
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Sequence

Expand All @@ -23,6 +24,7 @@ def ensure_logging_framework_not_altered():
LOGGER.handlers = before_handlers


@contextmanager
def check_os_environ():
old = os.environ.copy()
to_clean = {k: os.environ.pop(k, None) for k in {ENV_VAR_KEY, "TOX_WORK_DIR", "PYTHONPATH"}}
Expand Down Expand Up @@ -51,7 +53,16 @@ def check_os_environ():
pytest.fail(msg)


check_os_environ_stable = pytest.fixture(autouse=True)(check_os_environ)
@pytest.fixture(autouse=True)
def check_os_environ_stable(monkeypatch):
with check_os_environ():
yield
monkeypatch.undo()


@pytest.fixture(autouse=True)
def no_color(monkeypatch, check_os_environ_stable):
monkeypatch.setenv("NO_COLOR", "yes")


@pytest.fixture(name="tox_project")
Expand Down
5 changes: 2 additions & 3 deletions src/tox/tox_env/python/virtual_env/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ def package_env_name_type(self):

def install_package(self):
package = self.package_env.perform_packaging()
self.install_python_packages(
package, no_deps=True, develop=self.conf["package"] is PackageType.dev, force_reinstall=True,
)
develop = self.conf["package"] is PackageType.dev
self.install_python_packages(package, no_deps=True, develop=develop, force_reinstall=True)


@impl
Expand Down
39 changes: 18 additions & 21 deletions tests/unit/pytest/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ def test_init_base(tox_project):


def test_env_var(monkeypatch):
monkeypatch.setenv("MORE", "B")
monkeypatch.setenv("EXTRA", "1")
monkeypatch.setenv("PYTHONPATH", "yes")
gen = check_os_environ()
next(gen)
monkeypatch.setenv("MAGIC", "A")
monkeypatch.setenv("MORE", "D")
monkeypatch.delenv("EXTRA")

from tox.pytest import pytest as tox_pytest

exp = "test changed environ extra {'MAGIC': 'A'} miss {'EXTRA': '1'} diff {'MORE = B vs D'}"

def fail(msg):
assert msg == exp

monkeypatch.setattr(tox_pytest, "fail", fail)
try:
gen.send(None)
except StopIteration:
pass
with monkeypatch.context() as m:
m.setenv("MORE", "B")
m.setenv("EXTRA", "1")
m.setenv("PYTHONPATH", "yes")

with check_os_environ():
m.setenv("MAGIC", "A")
m.setenv("MORE", "D")
m.delenv("EXTRA")

from tox.pytest import pytest as tox_pytest

exp = "test changed environ extra {'MAGIC': 'A'} miss {'EXTRA': '1'} diff {'MORE = B vs D'}"

def fail(msg):
assert msg == exp

m.setattr(tox_pytest, "fail", fail)

0 comments on commit 4ec1dce

Please sign in to comment.