Looks fabulous, turn to a PR? Maybe move to a _pytest.deprecated plugin
Am 21.07.2016 00:47 schrieb "Bruno Oliveira" <[email protected]>: > > On Wed, Jul 20, 2016 at 6:31 PM Floris Bruynooghe [email protected] wrote: >> >> On 20 July 2016 at 21:50, holger krekel <[email protected]> wrote: >> > On Wed, Jul 20, 2016 at 16:15 +0000, Bruno Oliveira wrote: >> >> Hi Ronny, >> >> >> >> AFAIK there’s no simple way to workaround it, correct? For example, I >> >> believe there might be code out there using pytest.config as a conditional >> >> in a pytest.mark.skipif decorator. In this case the change is not a simple >> >> find/replace. >> > >> > You can use string-evaluation to get access to pytest's config: >> > >> > @pytest.mark.skipif("config.option.something == 'none'") >> > ... >> >> I'm probably with Bruno on this, seems like we might break too many test suites. > > I took a look and it seems the code involved is just this piece in main.py: > > def pytest_configure(config): pytest.config = config # compatibiltiy > > If that’s the case, I would rather officially deprecate it and keep it around a little more since those two lines are not really hurting maintenance. :). > > Any ideas on how to only issue a warning if the object is actually accessed? I thought something like this could do the trick: > > class _DeprecatedConfig(object): def __init__(self, config): self.__config = config self.__warned = False def __getattr__(self, attr): result = getattr(self, self.__config) if not self.__warned: self.__config.warn('pytest.config usage has been deprecated and will be removed in 4.0') self.__warned = True return result def pytest_configure(config): pytest.config = _DeprecatedConfig(config) > > What do you guys think? > >
_______________________________________________ pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
