Skip to content

Commit 4736b2b

Browse files
address review comments
1 parent 584051a commit 4736b2b

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ repos:
4343
- id: changelogs-rst
4444
name: changelog filenames
4545
language: fail
46-
entry: 'changelog files must be named ####.(feature|bugfix|doc|removal|vendor|trivial).rst'
46+
entry: 'changelog files must be named ####.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst'
4747
exclude: changelog/(\d+\.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst|README.rst|_template.rst)
4848
files: ^changelog/

changelog/3988.deprecation.rst

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

doc/en/tmpdir.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Temporary directories and files
66
================================================
77

88
The ``tmp_path`` fixture
9-
----------------------
9+
------------------------
1010

1111
.. versionadded:: 3.9
1212

@@ -15,12 +15,16 @@ You can use the ``tmpdir`` fixture which will
1515
provide a temporary directory unique to the test invocation,
1616
created in the `base temporary directory`_.
1717

18-
``tmpdir`` is a `pathlib/pathlib2.Path`_ object. Here is an example test usage::
18+
``tmpdir`` is a ``pathlib/pathlib2.Path`` object. Here is an example test usage:
19+
20+
.. code-block:: python
1921
2022
# content of test_tmp_path.py
2123
import os
24+
2225
CONTENT = u"content"
2326
27+
2428
def test_create_file(tmp_path):
2529
d = tmp_path / "sub"
2630
d.mkdir()
@@ -38,16 +42,16 @@ Running this would result in a passed test except for the last
3842

3943

4044

41-
The ``tmp_path_facotry`` fixture
42-
------------------------------
45+
The ``tmp_path_factory`` fixture
46+
--------------------------------
4347

4448
.. versionadded:: 3.9
4549

4650

4751
The ``tmp_path_facotry`` is a session-scoped fixture which can be used
4852
to create arbitrary temporary directories from any other fixture or test.
4953

50-
its intended to replace ``tmpdir_factory``
54+
its intended to replace ``tmpdir_factory`` and returns :class:`pathlib.Path` instances.
5155

5256

5357
The 'tmpdir' fixture

src/_pytest/tmpdir.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TempPathFactory(object):
2525
2626
The base directory can be configured using the ``--basetemp`` option."""
2727

28-
given_basetemp = attr.ib()
29-
trace = attr.ib()
28+
_given_basetemp = attr.ib()
29+
_trace = attr.ib()
3030
_basetemp = attr.ib(default=None)
3131

3232
@classmethod
@@ -45,14 +45,14 @@ def mktemp(self, basename, numbered=True):
4545
p.mkdir()
4646
else:
4747
p = make_numbered_dir(root=self.getbasetemp(), prefix=basename)
48-
self.trace("mktemp", p)
48+
self._trace("mktemp", p)
4949
return p
5050

5151
def getbasetemp(self):
5252
""" return base temporary directory. """
5353
if self._basetemp is None:
54-
if self.given_basetemp is not None:
55-
basetemp = Path(self.given_basetemp)
54+
if self._given_basetemp is not None:
55+
basetemp = Path(self._given_basetemp)
5656
ensure_reset_dir(basetemp)
5757
else:
5858
from_env = os.environ.get("PYTEST_DEBUG_TEMPROOT")
@@ -67,7 +67,7 @@ def getbasetemp(self):
6767
)
6868
assert basetemp is not None
6969
self._basetemp = t = basetemp
70-
self.trace("new basetemp", t)
70+
self._trace("new basetemp", t)
7171
return t
7272
else:
7373
return self._basetemp

0 commit comments

Comments
 (0)