minor: getbasetemp: dedent, improve assert (#5327)

minor: getbasetemp: dedent, improve assert
This commit is contained in:
Bruno Oliveira 2019-05-28 19:59:43 -03:00 committed by GitHub
commit 5bc3ad8e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 21 deletions

View File

@ -60,7 +60,9 @@ class TempPathFactory(object):
def getbasetemp(self):
""" return base temporary directory. """
if self._basetemp is None:
if self._basetemp is not None:
return self._basetemp
if self._given_basetemp is not None:
basetemp = self._given_basetemp
ensure_reset_dir(basetemp)
@ -76,12 +78,10 @@ class TempPathFactory(object):
basetemp = make_numbered_dir_with_cleanup(
prefix="pytest-", root=rootdir, keep=3, lock_timeout=LOCK_TIMEOUT
)
assert basetemp is not None
assert basetemp is not None, basetemp
self._basetemp = t = basetemp
self._trace("new basetemp", t)
return t
else:
return self._basetemp
@attr.s