style: use Black everywhere (#2594)

* style: use Black everywhere

* style: minor touchup from review
This commit is contained in:
Henry Schreiner
2020-10-16 16:38:13 -04:00
committed by GitHub
parent 2e31e466dc
commit c50f90eca6
38 changed files with 1653 additions and 941 deletions

View File

@@ -54,27 +54,27 @@ def test_python_alreadyset_in_destructor(monkeypatch, capsys):
hooked = False
triggered = [False] # mutable, so Python 2.7 closure can modify it
if hasattr(sys, 'unraisablehook'): # Python 3.8+
if hasattr(sys, "unraisablehook"): # Python 3.8+
hooked = True
default_hook = sys.unraisablehook
def hook(unraisable_hook_args):
exc_type, exc_value, exc_tb, err_msg, obj = unraisable_hook_args
if obj == 'already_set demo':
if obj == "already_set demo":
triggered[0] = True
default_hook(unraisable_hook_args)
return
# Use monkeypatch so pytest can apply and remove the patch as appropriate
monkeypatch.setattr(sys, 'unraisablehook', hook)
monkeypatch.setattr(sys, "unraisablehook", hook)
assert m.python_alreadyset_in_destructor('already_set demo') is True
assert m.python_alreadyset_in_destructor("already_set demo") is True
if hooked:
assert triggered[0] is True
_, captured_stderr = capsys.readouterr()
# Error message is different in Python 2 and 3, check for words that appear in both
assert 'ignored' in captured_stderr and 'already_set demo' in captured_stderr
assert "ignored" in captured_stderr and "already_set demo" in captured_stderr
def test_exception_matches():
@@ -107,7 +107,9 @@ def test_custom(msg):
# Can we fall-through to the default handler?
with pytest.raises(RuntimeError) as excinfo:
m.throws_logic_error()
assert msg(excinfo.value) == "this error should fall through to the standard handler"
assert (
msg(excinfo.value) == "this error should fall through to the standard handler"
)
# OverFlow error translation.
with pytest.raises(OverflowError) as excinfo:
@@ -166,7 +168,13 @@ def test_nested_throws(capture):
# C++ -> Python -> C++ -> Python
with capture:
m.try_catch(
m.MyException5, pycatch, m.MyException, m.try_catch, m.MyException, throw_myex5)
m.MyException5,
pycatch,
m.MyException,
m.try_catch,
m.MyException,
throw_myex5,
)
assert str(capture).startswith("MyException5: nested error 5")
# C++ -> Python -> C++
@@ -182,7 +190,6 @@ def test_nested_throws(capture):
# This can often happen if you wrap a pybind11 class in a Python wrapper
def test_invalid_repr():
class MyRepr(object):
def __repr__(self):
raise AttributeError("Example error")