MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_py3_str_slicing

Function test_py3_str_slicing

tests_python/test_safe_repr.py:601–626  ·  view source on GitHub ↗
(params, use_str)

Source from the content-addressed store, hash-verified

599)
600@pytest.mark.parametrize("use_str", [True, False])
601def test_py3_str_slicing(params, use_str):
602 # Note: much simpler in python because __repr__ is required to return str
603 safe_repr = SafeRepr()
604 safe_repr.locale_preferred_encoding = "ascii"
605 safe_repr.sys_stdout_encoding = params.get("sys_stdout_encoding", "ascii")
606
607 safe_repr.maxother_outer = params["maxother_outer"]
608
609 if not use_str:
610
611 class MyObj(object):
612 def __repr__(self):
613 return params["input"]
614
615 safe_repr_input = MyObj()
616 else:
617 safe_repr_input = params["input"]
618 expected_output = params["output"]
619 computed = safe_repr(safe_repr_input)
620 expected = repr(expected_output)
621 if use_str:
622 expected = repr(expected)
623 assert repr(computed) == expected
624
625 # Check that we can json-encode the return.
626 assert json.dumps(computed)
627
628
629def test_raw_bytes():

Callers

nothing calls this directly

Calls 4

SafeReprClass · 0.90
MyObjClass · 0.85
dumpsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected