MCPcopy Create free account
hub / github.com/ipython/ipython / eval_formatter_check

Function eval_formatter_check

IPython/utils/tests/test_text.py:96–115  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

94 nt.assert_equal(out, '\n'.join(items+['']), "row_first={0}".format(row_first))
95
96def eval_formatter_check(f):
97 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os, u=u"café", b="café")
98 s = f.format("{n} {n//4} {stuff.split()[0]}", **ns)
99 nt.assert_equal(s, "12 3 hello")
100 s = f.format(' '.join(['{n//%i}'%i for i in range(1,8)]), **ns)
101 nt.assert_equal(s, "12 6 4 3 2 2 1")
102 s = f.format('{[n//i for i in range(1,8)]}', **ns)
103 nt.assert_equal(s, "[12, 6, 4, 3, 2, 2, 1]")
104 s = f.format("{stuff!s}", **ns)
105 nt.assert_equal(s, ns['stuff'])
106 s = f.format("{stuff!r}", **ns)
107 nt.assert_equal(s, repr(ns['stuff']))
108
109 # Check with unicode:
110 s = f.format("{u}", **ns)
111 nt.assert_equal(s, ns['u'])
112 # This decodes in a platform dependent manner, but it shouldn't error out
113 s = f.format("{b}", **ns)
114
115 nt.assert_raises(NameError, f.format, '{dne}', **ns)
116
117def eval_formatter_slicing_check(f):
118 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)

Callers 3

test_eval_formatterFunction · 0.85
test_full_eval_formatterFunction · 0.85
test_dollar_formatterFunction · 0.85

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected