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

cache_dir: use $TOX_ENV_DIR/ prefix if set #4271

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Oct 30, 2018

Fixes #4270

"rst" pre-commit hook fails:

ERROR changelog/4270.feature.rst:1 Unknown interpreted text role "confval".

I think we should fix it to allow for our own roles etc. /cc @asottile

@asottile
Copy link
Member

The rst hook just invokes this tool -- not sure what to do about that

@blueyed
Copy link
Contributor Author

blueyed commented Oct 30, 2018

@asottile
I think https://github.com/twolfson/restructuredtext-lint#sphinx is relevant.
AFAIU it would require us to use a wrapper script, which registers our Sphinx directives first?

@blueyed blueyed changed the title cache_dir: use $TOX_ENV_DIR/ prefix if set [WIP] cache_dir: use $TOX_ENV_DIR/ prefix if set Oct 31, 2018
@blueyed
Copy link
Contributor Author

blueyed commented Oct 31, 2018

Is this good in general?
I have to adjust some tests, by just unsetting $TOX_ENV_DIR I assume.

@RonnyPfannschmidt
Copy link
Member

its good in general - i'd like better layering for it, but its not clear how to get that yet

@pytest.fixture(scope="function", autouse=True)
def handle_env(monkeypatch):
"""Ensure env is like most of the tests expect it, i.e. not using tox."""
monkeypatch.delenv("TOX_ENV_DIR", raising=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only gets used in this module/file then, right?
Might be worth requesting it explicitly though, but there are like 12+ files failing due to this.

@blueyed blueyed changed the title [WIP] cache_dir: use $TOX_ENV_DIR/ prefix if set cache_dir: use $TOX_ENV_DIR/ prefix if set Nov 9, 2018
@codecov
Copy link

codecov bot commented Nov 9, 2018

Codecov Report

Merging #4271 into features will decrease coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##           features    #4271      +/-   ##
============================================
- Coverage     95.84%   95.63%   -0.22%     
============================================
  Files           111      111              
  Lines         24898    24909      +11     
  Branches       2432     2434       +2     
============================================
- Hits          23863    23821      -42     
- Misses          737      775      +38     
- Partials        298      313      +15
Flag Coverage Δ
#docs ?
#doctesting ?
#linting ?
#linux 95.63% <100%> (ø) ⬆️
#nobyte ?
#numpy 41.65% <26.66%> (-0.02%) ⬇️
#pexpect 41.65% <26.66%> (-0.02%) ⬇️
#py27 93.9% <100%> (-0.11%) ⬇️
#py34 92.02% <100%> (+0.06%) ⬆️
#py35 92.04% <100%> (+0.06%) ⬆️
#py36 93.74% <100%> (-0.17%) ⬇️
#py37 92.19% <100%> (+0.06%) ⬆️
#trial 41.65% <26.66%> (-0.02%) ⬇️
#windows ?
#xdist 93.57% <100%> (ø) ⬆️
Impacted Files Coverage Δ
src/_pytest/cacheprovider.py 97.02% <100%> (+0.06%) ⬆️
testing/test_cacheprovider.py 99.71% <100%> (ø) ⬆️
testing/test_pathlib.py 91.17% <0%> (-8.83%) ⬇️
src/_pytest/assertion/util.py 92.92% <0%> (-5.19%) ⬇️
testing/test_tmpdir.py 94.33% <0%> (-4.41%) ⬇️
src/_pytest/capture.py 90.24% <0%> (-3.18%) ⬇️
src/_pytest/pathlib.py 88.46% <0%> (-2.2%) ⬇️
testing/acceptance_test.py 97.19% <0%> (-1.08%) ⬇️
src/_pytest/nodes.py 93.82% <0%> (-0.83%) ⬇️
src/_pytest/pytester.py 86.96% <0%> (-0.43%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c06057...a507f44. Read the comment docs.

@RonnyPfannschmidt
Copy link
Member

just pondering some thoughts after revisiting im wondering if we ought to support uri style values there
then we could support tox as a url value, but also allow people to more gracefully disable the cache or request other locations in general

@blueyed
Copy link
Contributor Author

blueyed commented Nov 9, 2018

@RonnyPfannschmidt
Sounds good, but would be a separate feature - the env is there as-is or it is not.

@RonnyPfannschmidt
Copy link
Member

@blueyed true

@blueyed blueyed merged commit b92530d into pytest-dev:features Nov 9, 2018
@blueyed blueyed deleted the pytest_cache branch November 9, 2018 08:09
@pytest.fixture(scope="module", autouse=True)
def handle_env():
"""Ensure env is like most of the tests expect it, i.e. not using tox."""
orig_env = os.environ.pop("TOX_ENV_DIR", None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also easily be written as:

@pytest.fixture(scope="module", autouse=True)
def handle_env(monkeypatch):
    monkeypatch.delenv('TOX_ENV_DIR', raising=False)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, ScopeMismatch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true, but in that case I would use "function" scope as the cost of patching for each test is negligible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, and used that initially IIRC, but then figured that it is at least something, if only for when stepping through hook callers via pdb.. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants