From 3db76ccf3d83e9ea2f4aa4640623f580a87f3ac5 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 4 Sep 2018 15:52:44 -0300 Subject: [PATCH] Fix Cache.warn function to issue a "config" warning --- src/_pytest/cacheprovider.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index f27a04549..791cf3a33 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -6,7 +6,6 @@ ignores the external pytest-cache """ from __future__ import absolute_import, division, print_function from collections import OrderedDict -import warnings import py import six @@ -34,6 +33,7 @@ See [the docs](https://docs.pytest.org/en/latest/cache.html) for more informatio @attr.s class Cache(object): _cachedir = attr.ib(repr=False) + _config = attr.ib(repr=False) @classmethod def for_config(cls, config): @@ -41,17 +41,18 @@ class Cache(object): if config.getoption("cacheclear") and cachedir.exists(): shutil.rmtree(str(cachedir)) cachedir.mkdir() - return cls(cachedir) + return cls(cachedir, config) @staticmethod def cache_dir_from_config(config): return paths.resolve_from_str(config.getini("cache_dir"), config.rootdir) def warn(self, fmt, **args): + from _pytest.warnings import _issue_config_warning from _pytest.warning_types import PytestWarning - warnings.warn( - message=fmt.format(**args) if args else fmt, category=PytestWarning + _issue_config_warning( + PytestWarning(fmt.format(**args) if args else fmt), self._config ) def makedir(self, name):