Remove 'tmpdir_factory.ensuretemp'

This commit is contained in:
Bruno Oliveira 2019-06-30 12:27:29 -03:00
parent 7e58defc15
commit aa1955de72
4 changed files with 8 additions and 31 deletions

View File

@ -13,6 +13,8 @@ removed:
* ``pytest.config`` global variable.
* ``tmpdir_factory.ensuretemp`` method.
For more information consult
`Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs.

View File

@ -9,7 +9,6 @@ All constants defined in this module should be either PytestWarning instances or
in case of warnings which need to format their messages.
"""
from _pytest.warning_types import PytestDeprecationWarning
from _pytest.warning_types import RemovedInPytest4Warning
YIELD_TESTS = "yield tests were removed in pytest 4.0 - {name} will be ignored"
@ -46,11 +45,6 @@ RESULT_LOG = PytestDeprecationWarning(
)
PYTEST_ENSURETEMP = RemovedInPytest4Warning(
"pytest/tmpdir_factory.ensuretemp is deprecated, \n"
"please use the tmp_path fixture or tmp_path_factory.mktemp"
)
PYTEST_LOGWARNING = PytestDeprecationWarning(
"pytest_logwarning is deprecated, no longer being called, and will be removed soon\n"
"please use pytest_warning_captured instead"

View File

@ -2,7 +2,6 @@
import os
import re
import tempfile
import warnings
import attr
import py
@ -85,19 +84,6 @@ class TempdirFactory:
_tmppath_factory = attr.ib()
def ensuretemp(self, string, dir=1):
""" (deprecated) return temporary directory path with
the given string as the trailing part. It is usually
better to use the 'tmpdir' function argument which
provides an empty unique-per-test-invocation directory
and is guaranteed to be empty.
"""
# py.log._apiwarn(">1.1", "use tmpdir function argument")
from .deprecated import PYTEST_ENSURETEMP
warnings.warn(PYTEST_ENSURETEMP, stacklevel=2)
return self.getbasetemp().ensure(string, dir=dir)
def mktemp(self, basename, numbered=True):
"""Create a subdirectory of the base temporary directory and return it.
If ``numbered``, ensure the directory is unique by adding a number
@ -135,7 +121,6 @@ def pytest_configure(config):
config._cleanup.append(mp.undo)
mp.setattr(config, "_tmp_path_factory", tmppath_handler, raising=False)
mp.setattr(config, "_tmpdirhandler", t, raising=False)
mp.setattr(pytest, "ensuretemp", t.ensuretemp, raising=False)
@pytest.fixture(scope="session")

View File

@ -14,13 +14,6 @@ def test_tmpdir_fixture(testdir):
results.stdout.fnmatch_lines(["*1 passed*"])
def test_ensuretemp(recwarn):
d1 = pytest.ensuretemp("hello")
d2 = pytest.ensuretemp("hello")
assert d1 == d2
assert d1.check(dir=1)
@attr.s
class FakeConfig:
basetemp = attr.ib()
@ -85,12 +78,15 @@ def test_basetemp(testdir):
p = testdir.makepyfile(
"""
import pytest
def test_1():
pytest.ensuretemp("hello")
def test_1(tmpdir_factory):
tmpdir_factory.mktemp('hello', numbered=False)
"""
)
result = testdir.runpytest(p, "--basetemp=%s" % mytemp, SHOW_PYTEST_WARNINGS_ARG)
result = testdir.runpytest(
p, "--basetemp=%s" % mytemp, SHOW_PYTEST_WARNINGS_ARG, "-s"
)
assert result.ret == 0
print(mytemp)
assert mytemp.join("hello").check()