_pformat_dispatch: pass through args (#6715)

This commit is contained in:
Daniel Hahler 2020-02-12 16:07:57 +01:00 committed by GitHub
parent d79179a239
commit b7ad4c2bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -99,5 +99,5 @@ class AlwaysDispatchingPrettyPrinter(pprint.PrettyPrinter):
def _pformat_dispatch(object, indent=1, width=80, depth=None, *, compact=False):
return AlwaysDispatchingPrettyPrinter(
indent=1, width=80, depth=None, compact=False
indent=indent, width=width, depth=depth, compact=compact
).pformat(object)

View File

@ -1,4 +1,5 @@
import pytest
from _pytest._io.saferepr import _pformat_dispatch
from _pytest._io.saferepr import saferepr
@ -147,3 +148,9 @@ def test_unicode():
val = "£€"
reprval = "'£€'"
assert saferepr(val) == reprval
def test_pformat_dispatch():
assert _pformat_dispatch("a") == "'a'"
assert _pformat_dispatch("a" * 10, width=5) == "'aaaaaaaaaa'"
assert _pformat_dispatch("foo bar", width=5) == "('foo '\n 'bar')"