Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3aa7e7

Browse files
committed
Remove nose.tools.assert_equal from more places.
1 parent 9bf8212 commit e3aa7e7

1 file changed

Lines changed: 51 additions & 46 deletions

File tree

IPython/utils/tests/test_text.py

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@ def test_columnize():
3232
items = [l*size for l in 'abcd']
3333

3434
out = text.columnize(items, displaywidth=80)
35-
nt.assert_equal(out, 'aaaaa bbbbb ccccc ddddd\n')
35+
assert out == "aaaaa bbbbb ccccc ddddd\n"
3636
out = text.columnize(items, displaywidth=25)
37-
nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
37+
assert out == "aaaaa ccccc\nbbbbb ddddd\n"
3838
out = text.columnize(items, displaywidth=12)
39-
nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
39+
assert out == "aaaaa ccccc\nbbbbb ddddd\n"
4040
out = text.columnize(items, displaywidth=10)
41-
nt.assert_equal(out, 'aaaaa\nbbbbb\nccccc\nddddd\n')
41+
assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
4242

4343
out = text.columnize(items, row_first=True, displaywidth=80)
44-
nt.assert_equal(out, 'aaaaa bbbbb ccccc ddddd\n')
44+
assert out == "aaaaa bbbbb ccccc ddddd\n"
4545
out = text.columnize(items, row_first=True, displaywidth=25)
46-
nt.assert_equal(out, 'aaaaa bbbbb\nccccc ddddd\n')
46+
assert out == "aaaaa bbbbb\nccccc ddddd\n"
4747
out = text.columnize(items, row_first=True, displaywidth=12)
48-
nt.assert_equal(out, 'aaaaa bbbbb\nccccc ddddd\n')
48+
assert out == "aaaaa bbbbb\nccccc ddddd\n"
4949
out = text.columnize(items, row_first=True, displaywidth=10)
50-
nt.assert_equal(out, 'aaaaa\nbbbbb\nccccc\nddddd\n')
50+
assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
5151

5252
out = text.columnize(items, displaywidth=40, spread=True)
53-
nt.assert_equal(out, 'aaaaa bbbbb ccccc ddddd\n')
53+
assert out == "aaaaa bbbbb ccccc ddddd\n"
5454
out = text.columnize(items, displaywidth=20, spread=True)
55-
nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
55+
assert out == "aaaaa ccccc\nbbbbb ddddd\n"
5656
out = text.columnize(items, displaywidth=12, spread=True)
57-
nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
57+
assert out == "aaaaa ccccc\nbbbbb ddddd\n"
5858
out = text.columnize(items, displaywidth=10, spread=True)
59-
nt.assert_equal(out, 'aaaaa\nbbbbb\nccccc\nddddd\n')
59+
assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
6060

6161

6262
def test_columnize_random():
@@ -77,38 +77,43 @@ def test_columnize_random():
7777
print("size of each element :\n %s" % rand_len)
7878
assert False, "row_first={0}".format(row_first)
7979

80+
81+
# TODO: pytest mark.parametrize once nose removed.
8082
def test_columnize_medium():
8183
"""Test with inputs than shouldn't be wider than 80"""
8284
size = 40
8385
items = [l*size for l in 'abc']
8486
for row_first in [True, False]:
8587
out = text.columnize(items, row_first=row_first, displaywidth=80)
86-
nt.assert_equal(out, '\n'.join(items+['']), "row_first={0}".format(row_first))
88+
assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
89+
8790

91+
# TODO: pytest mark.parametrize once nose removed.
8892
def test_columnize_long():
8993
"""Test columnize with inputs longer than the display window"""
9094
size = 11
9195
items = [l*size for l in 'abc']
9296
for row_first in [True, False]:
93-
out = text.columnize(items, row_first=row_first, displaywidth=size-1)
94-
nt.assert_equal(out, '\n'.join(items+['']), "row_first={0}".format(row_first))
97+
out = text.columnize(items, row_first=row_first, displaywidth=size - 1)
98+
assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
99+
95100

96101
def eval_formatter_check(f):
97102
ns = dict(n=12, pi=math.pi, stuff='hello there', os=os, u=u"café", b="café")
98103
s = f.format("{n} {n//4} {stuff.split()[0]}", **ns)
99-
nt.assert_equal(s, "12 3 hello")
104+
assert s == "12 3 hello"
100105
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")
106+
assert s == "12 6 4 3 2 2 1"
102107
s = f.format('{[n//i for i in range(1,8)]}', **ns)
103-
nt.assert_equal(s, "[12, 6, 4, 3, 2, 2, 1]")
108+
assert s == "[12, 6, 4, 3, 2, 2, 1]"
104109
s = f.format("{stuff!s}", **ns)
105-
nt.assert_equal(s, ns['stuff'])
110+
assert s == ns["stuff"]
106111
s = f.format("{stuff!r}", **ns)
107-
nt.assert_equal(s, repr(ns['stuff']))
108-
112+
assert s == repr(ns["stuff"])
113+
109114
# Check with unicode:
110115
s = f.format("{u}", **ns)
111-
nt.assert_equal(s, ns['u'])
116+
assert s == ns["u"]
112117
# This decodes in a platform dependent manner, but it shouldn't error out
113118
s = f.format("{b}", **ns)
114119

@@ -117,25 +122,25 @@ def eval_formatter_check(f):
117122
def eval_formatter_slicing_check(f):
118123
ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
119124
s = f.format(" {stuff.split()[:]} ", **ns)
120-
nt.assert_equal(s, " ['hello', 'there'] ")
125+
assert s == " ['hello', 'there'] "
121126
s = f.format(" {stuff.split()[::-1]} ", **ns)
122-
nt.assert_equal(s, " ['there', 'hello'] ")
127+
assert s == " ['there', 'hello'] "
123128
s = f.format("{stuff[::2]}", **ns)
124-
nt.assert_equal(s, ns['stuff'][::2])
125-
129+
assert s == ns["stuff"][::2]
130+
126131
nt.assert_raises(SyntaxError, f.format, "{n:x}", **ns)
127132

128133
def eval_formatter_no_slicing_check(f):
129134
ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
130135

131136
s = f.format('{n:x} {pi**2:+f}', **ns)
132-
nt.assert_equal(s, "c +9.869604")
133-
134-
s = f.format('{stuff[slice(1,4)]}', **ns)
135-
nt.assert_equal(s, 'ell')
137+
assert s == "c +9.869604"
138+
139+
s = f.format("{stuff[slice(1,4)]}", **ns)
140+
assert s == "ell"
136141

137142
s = f.format("{a[:]}", a=[1, 2])
138-
nt.assert_equal(s, "[1, 2]")
143+
assert s == "[1, 2]"
139144

140145
def test_eval_formatter():
141146
f = text.EvalFormatter()
@@ -154,15 +159,15 @@ def test_dollar_formatter():
154159

155160
ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
156161
s = f.format("$n", **ns)
157-
nt.assert_equal(s, "12")
162+
assert s == "12"
158163
s = f.format("$n.real", **ns)
159-
nt.assert_equal(s, "12")
164+
assert s == "12"
160165
s = f.format("$n/{stuff[:5]}", **ns)
161-
nt.assert_equal(s, "12/hello")
166+
assert s == "12/hello"
162167
s = f.format("$n $$HOME", **ns)
163-
nt.assert_equal(s, "12 $HOME")
168+
assert s == "12 $HOME"
164169
s = f.format("${foo}", foo="HOME")
165-
nt.assert_equal(s, "$HOME")
170+
assert s == "$HOME"
166171

167172

168173
def test_strip_email():
@@ -176,25 +181,25 @@ def test_strip_email():
176181
... return x+1
177182
...
178183
>>> zz = f(2.5)"""
179-
nt.assert_equal(text.strip_email_quotes(src), cln)
184+
assert text.strip_email_quotes(src) == cln
180185

181186

182187
def test_strip_email2():
183188
src = '> > > list()'
184189
cln = 'list()'
185-
nt.assert_equal(text.strip_email_quotes(src), cln)
190+
assert text.strip_email_quotes(src) == cln
186191

187192
def test_LSString():
188193
lss = text.LSString("abc\ndef")
189-
nt.assert_equal(lss.l, ['abc', 'def'])
190-
nt.assert_equal(lss.s, 'abc def')
194+
assert lss.l == ["abc", "def"]
195+
assert lss.s == "abc def"
191196
lss = text.LSString(os.getcwd())
192197
nt.assert_is_instance(lss.p[0], Path)
193198

194199
def test_SList():
195-
sl = text.SList(['a 11', 'b 1', 'a 2'])
196-
nt.assert_equal(sl.n, 'a 11\nb 1\na 2')
197-
nt.assert_equal(sl.s, 'a 11 b 1 a 2')
198-
nt.assert_equal(sl.grep(lambda x: x.startswith('a')), text.SList(['a 11', 'a 2']))
199-
nt.assert_equal(sl.fields(0), text.SList(['a', 'b', 'a']))
200-
nt.assert_equal(sl.sort(field=1, nums=True), text.SList(['b 1', 'a 2', 'a 11']))
200+
sl = text.SList(["a 11", "b 1", "a 2"])
201+
assert sl.n == "a 11\nb 1\na 2"
202+
assert sl.s == "a 11 b 1 a 2"
203+
assert sl.grep(lambda x: x.startswith("a")) == text.SList(["a 11", "a 2"])
204+
assert sl.fields(0) == text.SList(["a", "b", "a"])
205+
assert sl.sort(field=1, nums=True) == text.SList(["b 1", "a 2", "a 11"])

0 commit comments

Comments
 (0)