##// END OF EJS Templates
Remove nose.tools.assert_equal from more places.
Matthias Bussonnier -
Show More
@@ -32,31 +32,31 b' def test_columnize():'
32 items = [l*size for l in 'abcd']
32 items = [l*size for l in 'abcd']
33
33
34 out = text.columnize(items, displaywidth=80)
34 out = text.columnize(items, displaywidth=80)
35 nt.assert_equal(out, 'aaaaa bbbbb ccccc ddddd\n')
35 assert out == "aaaaa bbbbb ccccc ddddd\n"
36 out = text.columnize(items, displaywidth=25)
36 out = text.columnize(items, displaywidth=25)
37 nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
37 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
38 out = text.columnize(items, displaywidth=12)
38 out = text.columnize(items, displaywidth=12)
39 nt.assert_equal(out, 'aaaaa ccccc\nbbbbb ddddd\n')
39 assert out == "aaaaa ccccc\nbbbbb ddddd\n"
40 out = text.columnize(items, displaywidth=10)
40 out = text.columnize(items, displaywidth=10)
41 nt.assert_equal(out, 'aaaaa\nbbbbb\nccccc\nddddd\n')
41 assert out == "aaaaa\nbbbbb\nccccc\nddddd\n"
42
42
43 out = text.columnize(items, row_first=True, displaywidth=80)
43 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"
45 out = text.columnize(items, row_first=True, displaywidth=25)
45 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"
47 out = text.columnize(items, row_first=True, displaywidth=12)
47 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"
49 out = text.columnize(items, row_first=True, displaywidth=10)
49 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"
51
51
52 out = text.columnize(items, displaywidth=40, spread=True)
52 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"
54 out = text.columnize(items, displaywidth=20, spread=True)
54 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"
56 out = text.columnize(items, displaywidth=12, spread=True)
56 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"
58 out = text.columnize(items, displaywidth=10, spread=True)
58 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"
60
60
61
61
62 def test_columnize_random():
62 def test_columnize_random():
@@ -77,38 +77,43 b' def test_columnize_random():'
77 print("size of each element :\n %s" % rand_len)
77 print("size of each element :\n %s" % rand_len)
78 assert False, "row_first={0}".format(row_first)
78 assert False, "row_first={0}".format(row_first)
79
79
80
81 # TODO: pytest mark.parametrize once nose removed.
80 def test_columnize_medium():
82 def test_columnize_medium():
81 """Test with inputs than shouldn't be wider than 80"""
83 """Test with inputs than shouldn't be wider than 80"""
82 size = 40
84 size = 40
83 items = [l*size for l in 'abc']
85 items = [l*size for l in 'abc']
84 for row_first in [True, False]:
86 for row_first in [True, False]:
85 out = text.columnize(items, row_first=row_first, displaywidth=80)
87 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
87
90
91 # TODO: pytest mark.parametrize once nose removed.
88 def test_columnize_long():
92 def test_columnize_long():
89 """Test columnize with inputs longer than the display window"""
93 """Test columnize with inputs longer than the display window"""
90 size = 11
94 size = 11
91 items = [l*size for l in 'abc']
95 items = [l*size for l in 'abc']
92 for row_first in [True, False]:
96 for row_first in [True, False]:
93 out = text.columnize(items, row_first=row_first, displaywidth=size-1)
97 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))
98 assert out == "\n".join(items + [""]), "row_first={0}".format(row_first)
99
95
100
96 def eval_formatter_check(f):
101 def eval_formatter_check(f):
97 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os, u=u"cafΓ©", b="cafΓ©")
102 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)
103 s = f.format("{n} {n//4} {stuff.split()[0]}", **ns)
99 nt.assert_equal(s, "12 3 hello")
104 assert s == "12 3 hello"
100 s = f.format(' '.join(['{n//%i}'%i for i in range(1,8)]), **ns)
105 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"
102 s = f.format('{[n//i for i in range(1,8)]}', **ns)
107 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]"
104 s = f.format("{stuff!s}", **ns)
109 s = f.format("{stuff!s}", **ns)
105 nt.assert_equal(s, ns['stuff'])
110 assert s == ns["stuff"]
106 s = f.format("{stuff!r}", **ns)
111 s = f.format("{stuff!r}", **ns)
107 nt.assert_equal(s, repr(ns['stuff']))
112 assert s == repr(ns["stuff"])
108
113
109 # Check with unicode:
114 # Check with unicode:
110 s = f.format("{u}", **ns)
115 s = f.format("{u}", **ns)
111 nt.assert_equal(s, ns['u'])
116 assert s == ns["u"]
112 # This decodes in a platform dependent manner, but it shouldn't error out
117 # This decodes in a platform dependent manner, but it shouldn't error out
113 s = f.format("{b}", **ns)
118 s = f.format("{b}", **ns)
114
119
@@ -117,25 +122,25 b' def eval_formatter_check(f):'
117 def eval_formatter_slicing_check(f):
122 def eval_formatter_slicing_check(f):
118 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
123 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
119 s = f.format(" {stuff.split()[:]} ", **ns)
124 s = f.format(" {stuff.split()[:]} ", **ns)
120 nt.assert_equal(s, " ['hello', 'there'] ")
125 assert s == " ['hello', 'there'] "
121 s = f.format(" {stuff.split()[::-1]} ", **ns)
126 s = f.format(" {stuff.split()[::-1]} ", **ns)
122 nt.assert_equal(s, " ['there', 'hello'] ")
127 assert s == " ['there', 'hello'] "
123 s = f.format("{stuff[::2]}", **ns)
128 s = f.format("{stuff[::2]}", **ns)
124 nt.assert_equal(s, ns['stuff'][::2])
129 assert s == ns["stuff"][::2]
125
130
126 nt.assert_raises(SyntaxError, f.format, "{n:x}", **ns)
131 nt.assert_raises(SyntaxError, f.format, "{n:x}", **ns)
127
132
128 def eval_formatter_no_slicing_check(f):
133 def eval_formatter_no_slicing_check(f):
129 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
134 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
130
135
131 s = f.format('{n:x} {pi**2:+f}', **ns)
136 s = f.format('{n:x} {pi**2:+f}', **ns)
132 nt.assert_equal(s, "c +9.869604")
137 assert s == "c +9.869604"
133
138
134 s = f.format('{stuff[slice(1,4)]}', **ns)
139 s = f.format("{stuff[slice(1,4)]}", **ns)
135 nt.assert_equal(s, 'ell')
140 assert s == "ell"
136
141
137 s = f.format("{a[:]}", a=[1, 2])
142 s = f.format("{a[:]}", a=[1, 2])
138 nt.assert_equal(s, "[1, 2]")
143 assert s == "[1, 2]"
139
144
140 def test_eval_formatter():
145 def test_eval_formatter():
141 f = text.EvalFormatter()
146 f = text.EvalFormatter()
@@ -154,15 +159,15 b' def test_dollar_formatter():'
154
159
155 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
160 ns = dict(n=12, pi=math.pi, stuff='hello there', os=os)
156 s = f.format("$n", **ns)
161 s = f.format("$n", **ns)
157 nt.assert_equal(s, "12")
162 assert s == "12"
158 s = f.format("$n.real", **ns)
163 s = f.format("$n.real", **ns)
159 nt.assert_equal(s, "12")
164 assert s == "12"
160 s = f.format("$n/{stuff[:5]}", **ns)
165 s = f.format("$n/{stuff[:5]}", **ns)
161 nt.assert_equal(s, "12/hello")
166 assert s == "12/hello"
162 s = f.format("$n $$HOME", **ns)
167 s = f.format("$n $$HOME", **ns)
163 nt.assert_equal(s, "12 $HOME")
168 assert s == "12 $HOME"
164 s = f.format("${foo}", foo="HOME")
169 s = f.format("${foo}", foo="HOME")
165 nt.assert_equal(s, "$HOME")
170 assert s == "$HOME"
166
171
167
172
168 def test_strip_email():
173 def test_strip_email():
@@ -176,25 +181,25 b' def test_strip_email():'
176 ... return x+1
181 ... return x+1
177 ...
182 ...
178 >>> zz = f(2.5)"""
183 >>> zz = f(2.5)"""
179 nt.assert_equal(text.strip_email_quotes(src), cln)
184 assert text.strip_email_quotes(src) == cln
180
185
181
186
182 def test_strip_email2():
187 def test_strip_email2():
183 src = '> > > list()'
188 src = '> > > list()'
184 cln = 'list()'
189 cln = 'list()'
185 nt.assert_equal(text.strip_email_quotes(src), cln)
190 assert text.strip_email_quotes(src) == cln
186
191
187 def test_LSString():
192 def test_LSString():
188 lss = text.LSString("abc\ndef")
193 lss = text.LSString("abc\ndef")
189 nt.assert_equal(lss.l, ['abc', 'def'])
194 assert lss.l == ["abc", "def"]
190 nt.assert_equal(lss.s, 'abc def')
195 assert lss.s == "abc def"
191 lss = text.LSString(os.getcwd())
196 lss = text.LSString(os.getcwd())
192 nt.assert_is_instance(lss.p[0], Path)
197 nt.assert_is_instance(lss.p[0], Path)
193
198
194 def test_SList():
199 def test_SList():
195 sl = text.SList(['a 11', 'b 1', 'a 2'])
200 sl = text.SList(["a 11", "b 1", "a 2"])
196 nt.assert_equal(sl.n, 'a 11\nb 1\na 2')
201 assert sl.n == "a 11\nb 1\na 2"
197 nt.assert_equal(sl.s, 'a 11 b 1 a 2')
202 assert 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']))
203 assert 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']))
204 assert 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']))
205 assert sl.sort(field=1, nums=True) == text.SList(["b 1", "a 2", "a 11"])
General Comments 0
You need to be logged in to leave comments. Login now