Merge remote-tracking branch 'upstream/master' into merge-master-into-features
This commit is contained in:
@@ -389,13 +389,13 @@ class PytestPluginManager(PluginManager):
|
||||
if self._noconftest:
|
||||
return []
|
||||
|
||||
if path.isfile():
|
||||
directory = path.dirpath()
|
||||
else:
|
||||
directory = path
|
||||
try:
|
||||
return self._path2confmods[directory]
|
||||
return self._path2confmods[path]
|
||||
except KeyError:
|
||||
if path.isfile():
|
||||
directory = path.dirpath()
|
||||
else:
|
||||
directory = path
|
||||
# XXX these days we may rather want to use config.rootdir
|
||||
# and allow users to opt into looking into the rootdir parent
|
||||
# directories instead of requiring to specify confcutdir
|
||||
@@ -408,7 +408,7 @@ class PytestPluginManager(PluginManager):
|
||||
mod = self._importconftest(conftestpath)
|
||||
clist.append(mod)
|
||||
|
||||
self._path2confmods[directory] = clist
|
||||
self._path2confmods[path] = clist
|
||||
return clist
|
||||
|
||||
def _rget_with_confmod(self, name, path):
|
||||
|
||||
@@ -151,7 +151,7 @@ def create_cleanup_lock(p):
|
||||
else:
|
||||
pid = os.getpid()
|
||||
spid = str(pid)
|
||||
if not isinstance(spid, six.binary_type):
|
||||
if not isinstance(spid, bytes):
|
||||
spid = spid.encode("ascii")
|
||||
os.write(fd, spid)
|
||||
os.close(fd)
|
||||
@@ -177,9 +177,15 @@ def register_cleanup_lock_removal(lock_path, register=atexit.register):
|
||||
return register(cleanup_on_exit)
|
||||
|
||||
|
||||
def delete_a_numbered_dir(path):
|
||||
"""removes a numbered directory"""
|
||||
create_cleanup_lock(path)
|
||||
def maybe_delete_a_numbered_dir(path):
|
||||
"""removes a numbered directory if its lock can be obtained"""
|
||||
try:
|
||||
create_cleanup_lock(path)
|
||||
except (OSError, EnvironmentError):
|
||||
# known races:
|
||||
# * other process did a cleanup at the same time
|
||||
# * deletable folder was found
|
||||
return
|
||||
parent = path.parent
|
||||
|
||||
garbage = parent.joinpath("garbage-{}".format(uuid.uuid4()))
|
||||
@@ -209,7 +215,7 @@ def ensure_deletable(path, consider_lock_dead_if_created_before):
|
||||
def try_cleanup(path, consider_lock_dead_if_created_before):
|
||||
"""tries to cleanup a folder if we can ensure its deletable"""
|
||||
if ensure_deletable(path, consider_lock_dead_if_created_before):
|
||||
delete_a_numbered_dir(path)
|
||||
maybe_delete_a_numbered_dir(path)
|
||||
|
||||
|
||||
def cleanup_candidates(root, prefix, keep):
|
||||
|
||||
@@ -156,21 +156,27 @@ class WarningsRecorder(warnings.catch_warnings):
|
||||
# trivial patching of `warnings.warn` seems to be enough somehow?
|
||||
if six.PY2:
|
||||
|
||||
def warn(*args, **kwargs):
|
||||
kwargs.setdefault("stacklevel", 1)
|
||||
kwargs["stacklevel"] += 1
|
||||
def warn(message, category=None, stacklevel=1):
|
||||
# duplicate the stdlib logic due to
|
||||
# bad handing in the c version of warnings
|
||||
if isinstance(message, Warning):
|
||||
category = message.__class__
|
||||
# Check category argument
|
||||
if category is None:
|
||||
category = UserWarning
|
||||
assert issubclass(category, Warning)
|
||||
|
||||
# emulate resetting the warn registry
|
||||
f_globals = sys._getframe(kwargs["stacklevel"] - 1).f_globals
|
||||
f_globals = sys._getframe(stacklevel).f_globals
|
||||
if "__warningregistry__" in f_globals:
|
||||
orig = f_globals["__warningregistry__"]
|
||||
f_globals["__warningregistry__"] = None
|
||||
try:
|
||||
return self._saved_warn(*args, **kwargs)
|
||||
return self._saved_warn(message, category, stacklevel + 1)
|
||||
finally:
|
||||
f_globals["__warningregistry__"] = orig
|
||||
else:
|
||||
return self._saved_warn(*args, **kwargs)
|
||||
return self._saved_warn(message, category, stacklevel + 1)
|
||||
|
||||
warnings.warn, self._saved_warn = warn, warnings.warn
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user