address review comments

This commit is contained in:
Ronny Pfannschmidt 2018-10-11 15:33:19 +02:00
parent 584051aa90
commit 4736b2bdfb
4 changed files with 17 additions and 12 deletions

View File

@ -43,6 +43,6 @@ repos:
- id: changelogs-rst
name: changelog filenames
language: fail
entry: 'changelog files must be named ####.(feature|bugfix|doc|removal|vendor|trivial).rst'
entry: 'changelog files must be named ####.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst'
exclude: changelog/(\d+\.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst|README.rst|_template.rst)
files: ^changelog/

View File

@ -0,0 +1 @@
Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.

View File

@ -6,7 +6,7 @@ Temporary directories and files
================================================
The ``tmp_path`` fixture
----------------------
------------------------
.. versionadded:: 3.9
@ -15,12 +15,16 @@ You can use the ``tmpdir`` fixture which will
provide a temporary directory unique to the test invocation,
created in the `base temporary directory`_.
``tmpdir`` is a `pathlib/pathlib2.Path`_ object. Here is an example test usage::
``tmpdir`` is a ``pathlib/pathlib2.Path`` object. Here is an example test usage:
.. code-block:: python
# content of test_tmp_path.py
import os
CONTENT = u"content"
def test_create_file(tmp_path):
d = tmp_path / "sub"
d.mkdir()
@ -38,8 +42,8 @@ Running this would result in a passed test except for the last
The ``tmp_path_facotry`` fixture
------------------------------
The ``tmp_path_factory`` fixture
--------------------------------
.. versionadded:: 3.9
@ -47,7 +51,7 @@ The ``tmp_path_facotry`` fixture
The ``tmp_path_facotry`` is a session-scoped fixture which can be used
to create arbitrary temporary directories from any other fixture or test.
its intended to replace ``tmpdir_factory``
its intended to replace ``tmpdir_factory`` and returns :class:`pathlib.Path` instances.
The 'tmpdir' fixture

View File

@ -25,8 +25,8 @@ class TempPathFactory(object):
The base directory can be configured using the ``--basetemp`` option."""
given_basetemp = attr.ib()
trace = attr.ib()
_given_basetemp = attr.ib()
_trace = attr.ib()
_basetemp = attr.ib(default=None)
@classmethod
@ -45,14 +45,14 @@ class TempPathFactory(object):
p.mkdir()
else:
p = make_numbered_dir(root=self.getbasetemp(), prefix=basename)
self.trace("mktemp", p)
self._trace("mktemp", p)
return p
def getbasetemp(self):
""" return base temporary directory. """
if self._basetemp is None:
if self.given_basetemp is not None:
basetemp = Path(self.given_basetemp)
if self._given_basetemp is not None:
basetemp = Path(self._given_basetemp)
ensure_reset_dir(basetemp)
else:
from_env = os.environ.get("PYTEST_DEBUG_TEMPROOT")
@ -67,7 +67,7 @@ class TempPathFactory(object):
)
assert basetemp is not None
self._basetemp = t = basetemp
self.trace("new basetemp", t)
self._trace("new basetemp", t)
return t
else:
return self._basetemp