Merge the AlwaysDispathPrettyPrinter into the now vendored PrettyPrinter

We don't need to keep the separation anymore, and this will make it
easier to extend
This commit is contained in:
Benjamin Schubert
2023-11-18 09:07:00 +00:00
parent 2953120003
commit 19934b2b0c
5 changed files with 34 additions and 84 deletions

View File

@@ -0,0 +1,8 @@
from _pytest._io.pprint import PrettyPrinter
def test_pformat_dispatch():
printer = PrettyPrinter(width=5)
assert printer.pformat("a") == "'a'"
assert printer.pformat("a" * 10) == "'aaaaaaaaaa'"
assert printer.pformat("foo bar") == "('foo '\n 'bar')"

View File

@@ -1,5 +1,4 @@
import pytest
from _pytest._io.saferepr import _pformat_dispatch
from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
from _pytest._io.saferepr import saferepr
from _pytest._io.saferepr import saferepr_unlimited
@@ -159,12 +158,6 @@ def test_unicode():
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')"
def test_broken_getattribute():
"""saferepr() can create proper representations of classes with
broken __getattribute__ (#7145)