Method
_ensuredirs
src/_pytest/_py/path.py:931–945
· src/_pytest/_py/path.py::LocalPath._ensuredirs
(self)
Source from the content-addressed store, hash-verified
| 929 | f.close() |
| 930 | |
| 931 | def _ensuredirs(self): |
| 932 | parent = self.dirpath() |
| 933 | if parent == self: |
| 934 | return self |
| 935 | if parent.check(dir=0): |
| 936 | parent._ensuredirs() |
| 937 | if self.check(dir=0): |
| 938 | try: |
| 939 | self.mkdir() |
| 940 | except error.EEXIST: |
| 941 | class="cm"># race condition: file/dir created by another thread/process. |
| 942 | class="cm"># complain if it is not a dir |
| 943 | if self.check(dir=0): |
| 944 | raise |
| 945 | return self |
| 946 | |
| 947 | def ensure(self, *args, **kwargs): |
| 948 | class="st">"""Ensure that an args-joined path exists (by default as |
Tested by
no test coverage detected