Skip to content

Commit 56c3026

Browse files
committed
fix the order of arguments of assert_equal in tests
1 parent e52c5ba commit 56c3026

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

test/test_internal.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_multiline_width():
1616
def test_align_column_decimal():
1717
"Internal: _align_column(..., 'decimal')"
1818
column = ["12.345", "-1234.5", "1.23", "1234.5", "1e+234", "1.0e234"]
19-
output = T._align_column(column, "decimal")
19+
result = T._align_column(column, "decimal")
2020
expected = [
2121
" 12.345 ",
2222
"-1234.5 ",
@@ -25,7 +25,7 @@ def test_align_column_decimal():
2525
" 1e+234 ",
2626
" 1.0e234",
2727
]
28-
assert_equal(output, expected)
28+
assert_equal(expected, result)
2929

3030

3131
def test_align_column_decimal_with_thousand_separators():
@@ -40,7 +40,7 @@ def test_align_column_decimal_with_thousand_separators():
4040
" 1e+234 ",
4141
" 1.0e234",
4242
]
43-
assert_equal(output, expected)
43+
assert_equal(expected, output)
4444

4545

4646
def test_align_column_decimal_with_incorrect_thousand_separators():
@@ -55,23 +55,23 @@ def test_align_column_decimal_with_incorrect_thousand_separators():
5555
" 1e+234 ",
5656
" 1.0e234",
5757
]
58-
assert_equal(output, expected)
58+
assert_equal(expected, output)
5959

6060

6161
def test_align_column_none():
6262
"Internal: _align_column(..., None)"
6363
column = ["123.4", "56.7890"]
6464
output = T._align_column(column, None)
6565
expected = ["123.4", "56.7890"]
66-
assert_equal(output, expected)
66+
assert_equal(expected, output)
6767

6868

6969
def test_align_column_multiline():
7070
"Internal: _align_column(..., is_multiline=True)"
7171
column = ["1", "123", "12345\n6"]
7272
output = T._align_column(column, "center", is_multiline=True)
7373
expected = [" 1 ", " 123 ", "12345" + "\n" + " 6 "]
74-
assert_equal(output, expected)
74+
assert_equal(expected, output)
7575

7676

7777
def test_align_cell_veritically_one_line_only():
@@ -170,7 +170,7 @@ def test_wrap_text_to_colwidths():
170170
]
171171
result = T._wrap_text_to_colwidths(rows, widths)
172172

173-
assert_equal(result, expected)
173+
assert_equal(expected, result)
174174

175175

176176
def test_wrap_text_wide_chars():
@@ -185,7 +185,7 @@ def test_wrap_text_wide_chars():
185185
expected = [["청자\n청자\n청자\n청자\n청자", "약간 감싸면 더 잘\n보일 수있는 다소 긴\n설명입니다"]]
186186
result = T._wrap_text_to_colwidths(rows, widths)
187187

188-
assert_equal(result, expected)
188+
assert_equal(expected, result)
189189

190190

191191
def test_wrap_text_to_numbers():
@@ -202,7 +202,7 @@ def test_wrap_text_to_numbers():
202202
]
203203

204204
result = T._wrap_text_to_colwidths(rows, widths, numparses=[True, True, False])
205-
assert_equal(result, expected)
205+
assert_equal(expected, result)
206206

207207

208208
def test_wrap_text_to_colwidths_single_ansi_colors_full_cell():

test/test_output.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ def test_dict_like_with_index():
28472847
dd = {"b": range(101, 104)}
28482848
expected = "\n".join([" b", "-- ---", " 0 101", " 1 102", " 2 103"])
28492849
result = tabulate(dd, "keys", showindex=True)
2850-
assert_equal(result, expected)
2850+
assert_equal(expected, result)
28512851

28522852

28532853
def test_list_of_lists_with_index():
@@ -2859,7 +2859,7 @@ def test_list_of_lists_with_index():
28592859
[" a b", "-- --- ---", " 0 0 101", " 1 1 102", " 2 2 103"]
28602860
)
28612861
result = tabulate(dd, headers=["a", "b"], showindex=True)
2862-
assert_equal(result, expected)
2862+
assert_equal(expected, result)
28632863

28642864

28652865
def test_list_of_lists_with_index_with_sep_line():
@@ -2878,7 +2878,7 @@ def test_list_of_lists_with_index_with_sep_line():
28782878
]
28792879
)
28802880
result = tabulate(dd, headers=["a", "b"], showindex=True)
2881-
assert_equal(result, expected)
2881+
assert_equal(expected, result)
28822882

28832883

28842884
def test_list_of_lists_with_supplied_index():
@@ -2888,7 +2888,7 @@ def test_list_of_lists_with_supplied_index():
28882888
[" a b", "-- --- ---", " 1 0 101", " 2 1 102", " 3 2 103"]
28892889
)
28902890
result = tabulate(dd, headers=["a", "b"], showindex=[1, 2, 3])
2891-
assert_equal(result, expected)
2891+
assert_equal(expected, result)
28922892
# TODO: make it a separate test case
28932893
# the index must be as long as the number of rows
28942894
with raises(ValueError):
@@ -2902,7 +2902,7 @@ def test_list_of_lists_with_index_firstrow():
29022902
[" a b", "-- --- ---", " 0 0 101", " 1 1 102", " 2 2 103"]
29032903
)
29042904
result = tabulate(dd, headers="firstrow", showindex=True)
2905-
assert_equal(result, expected)
2905+
assert_equal(expected, result)
29062906
# TODO: make it a separate test case
29072907
# the index must be as long as the number of rows
29082908
with raises(ValueError):

test/test_regression.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ def test_column_type_of_bytestring_columns():
163163

164164
result = _column_type([b"foo", b"bar"])
165165
expected = bytes
166-
assert_equal(result, expected)
166+
assert_equal(expected, result)
167167

168168

169169
def test_numeric_column_headers():
170170
"Regression: numbers as column headers (issue #22)"
171171
result = tabulate([[1], [2]], [42])
172172
expected = " 42\n----\n 1\n 2"
173-
assert_equal(result, expected)
173+
assert_equal(expected, result)
174174

175175
lod = [{p: i for p in range(5)} for i in range(5)]
176176
result = tabulate(lod, "keys")
@@ -185,7 +185,7 @@ def test_numeric_column_headers():
185185
" 4 4 4 4 4",
186186
]
187187
)
188-
assert_equal(result, expected)
188+
assert_equal(expected, result)
189189

190190

191191
def test_88_256_ANSI_color_codes():
@@ -226,14 +226,14 @@ def test_latex_escape_special_chars():
226226
]
227227
)
228228
result = tabulate([["&%^_$#{}<>~"]], ["foo^bar"], tablefmt="latex")
229-
assert_equal(result, expected)
229+
assert_equal(expected, result)
230230

231231

232232
def test_isconvertible_on_set_values():
233233
"Regression: don't fail with TypeError on set values (issue #35)"
234234
expected = "\n".join(["a b", "--- -----", "Foo set()"])
235235
result = tabulate([["Foo", set()]], headers=["a", "b"])
236-
assert_equal(result, expected)
236+
assert_equal(expected, result)
237237

238238

239239
def test_ansi_color_for_decimal_numbers():
@@ -243,7 +243,7 @@ def test_ansi_color_for_decimal_numbers():
243243
["------- ---", "Magenta \x1b[95m1.1\x1b[0m", "------- ---"]
244244
)
245245
result = tabulate(table)
246-
assert_equal(result, expected)
246+
assert_equal(expected, result)
247247

248248

249249
def test_alignment_of_decimal_numbers_with_ansi_color():
@@ -253,7 +253,7 @@ def test_alignment_of_decimal_numbers_with_ansi_color():
253253
table = [[v1], [v2]]
254254
expected = "\n".join(["\x1b[95m12.34\x1b[0m", " \x1b[95m1.23456\x1b[0m"])
255255
result = tabulate(table, tablefmt="plain")
256-
assert_equal(result, expected)
256+
assert_equal(expected, result)
257257

258258

259259
def test_alignment_of_decimal_numbers_with_commas():
@@ -266,15 +266,15 @@ def test_alignment_of_decimal_numbers_with_commas():
266266
# '+------+-----------+', '| c1r2 | 105.00 |',
267267
# '+------+-----------+']
268268
# )
269-
# assert_equal(result, expected)
269+
# assert_equal(expected, result)
270270

271271

272272
def test_long_integers():
273273
"Regression: long integers should be printed as integers (issue #48)"
274274
table = [[18446744073709551614]]
275275
result = tabulate(table, tablefmt="plain")
276276
expected = "18446744073709551614"
277-
assert_equal(result, expected)
277+
assert_equal(expected, result)
278278

279279

280280
def test_colorclass_colors():
@@ -285,7 +285,7 @@ def test_colorclass_colors():
285285
s = colorclass.Color("{magenta}3.14{/magenta}")
286286
result = tabulate([[s]], tablefmt="plain")
287287
expected = "\x1b[35m3.14\x1b[39m"
288-
assert_equal(result, expected)
288+
assert_equal(expected, result)
289289
except ImportError:
290290

291291
class textclass(str):
@@ -294,7 +294,7 @@ class textclass(str):
294294
s = textclass("\x1b[35m3.14\x1b[39m")
295295
result = tabulate([[s]], tablefmt="plain")
296296
expected = "\x1b[35m3.14\x1b[39m"
297-
assert_equal(result, expected)
297+
assert_equal(expected, result)
298298

299299

300300
def test_mix_normal_and_wide_characters():
@@ -314,7 +314,7 @@ def test_mix_normal_and_wide_characters():
314314
"+--------+",
315315
]
316316
)
317-
assert_equal(result, expected)
317+
assert_equal(expected, result)
318318
except ImportError:
319319
skip("test_mix_normal_and_wide_characters is skipped (requires wcwidth lib)")
320320

@@ -334,7 +334,7 @@ def test_multiline_with_wide_characters():
334334
"╘══════╧══════╧══════╛",
335335
]
336336
)
337-
assert_equal(result, expected)
337+
assert_equal(expected, result)
338338
except ImportError:
339339
skip("test_multiline_with_wide_characters is skipped (requires wcwidth lib)")
340340

@@ -344,7 +344,7 @@ def test_align_long_integers():
344344
table = [[int(1)], [int(234)]]
345345
result = tabulate(table, tablefmt="plain")
346346
expected = "\n".join([" 1", "234"])
347-
assert_equal(result, expected)
347+
assert_equal(expected, result)
348348

349349

350350
def test_numpy_array_as_headers():
@@ -355,7 +355,7 @@ def test_numpy_array_as_headers():
355355
headers = np.array(["foo", "bar"])
356356
result = tabulate([], headers, tablefmt="plain")
357357
expected = "foo bar"
358-
assert_equal(result, expected)
358+
assert_equal(expected, result)
359359
except ImportError:
360360
raise skip("")
361361

@@ -365,7 +365,7 @@ def test_boolean_columns():
365365
xortable = [[False, True], [True, False]]
366366
expected = "\n".join(["False True", "True False"])
367367
result = tabulate(xortable, tablefmt="plain")
368-
assert_equal(result, expected)
368+
assert_equal(expected, result)
369369

370370

371371
def test_ansi_color_bold_and_fgcolor():
@@ -383,14 +383,14 @@ def test_ansi_color_bold_and_fgcolor():
383383
"+---+---+---+",
384384
]
385385
)
386-
assert_equal(result, expected)
386+
assert_equal(expected, result)
387387

388388

389389
def test_empty_table_with_keys_as_header():
390390
"Regression: headers='keys' on an empty table (issue #81)"
391391
result = tabulate([], headers="keys")
392392
expected = ""
393-
assert_equal(result, expected)
393+
assert_equal(expected, result)
394394

395395

396396
def test_escape_empty_cell_in_first_column_in_rst():
@@ -409,15 +409,15 @@ def test_escape_empty_cell_in_first_column_in_rst():
409409
]
410410
)
411411
result = tabulate(table, headers, tablefmt="rst")
412-
assert_equal(result, expected)
412+
assert_equal(expected, result)
413413

414414

415415
def test_ragged_rows():
416416
"Regression: allow rows with different number of columns (issue #85)"
417417
table = [[1, 2, 3], [1, 2], [1, 2, 3, 4]]
418418
expected = "\n".join(["- - - -", "1 2 3", "1 2", "1 2 3 4", "- - - -"])
419419
result = tabulate(table)
420-
assert_equal(result, expected)
420+
assert_equal(expected, result)
421421

422422

423423
def test_empty_pipe_table_with_columns():
@@ -426,7 +426,7 @@ def test_empty_pipe_table_with_columns():
426426
headers = ["Col1", "Col2"]
427427
expected = "\n".join(["| Col1 | Col2 |", "|--------|--------|"])
428428
result = tabulate(table, headers, tablefmt="pipe")
429-
assert_equal(result, expected)
429+
assert_equal(expected, result)
430430

431431

432432
def test_custom_tablefmt():
@@ -444,15 +444,15 @@ def test_custom_tablefmt():
444444
rows = [["foo", "bar"], ["baz", "qux"]]
445445
expected = "\n".join(["A B", "--- ---", "foo bar", "baz qux"])
446446
result = tabulate(rows, headers=["A", "B"], tablefmt=tablefmt)
447-
assert_equal(result, expected)
447+
assert_equal(expected, result)
448448

449449

450450
def test_string_with_comma_between_digits_without_floatfmt_grouping_option():
451451
"Regression: accept commas in numbers-as-text when grouping is not defined (github issue #110)"
452452
table = [["126,000"]]
453453
expected = "126,000"
454454
result = tabulate(table, tablefmt="plain")
455-
assert_equal(result, expected) # no exception
455+
assert_equal(expected, result) # no exception
456456

457457

458458
def test_iterable_row_index():
@@ -469,7 +469,7 @@ def count(start, step=1):
469469

470470
expected = "1 a\n2 b\n3 c"
471471
result = tabulate(table, showindex=count(1), tablefmt="plain")
472-
assert_equal(result, expected)
472+
assert_equal(expected, result)
473473

474474

475475
def test_preserve_line_breaks_with_maxcolwidths():
@@ -485,7 +485,7 @@ def test_preserve_line_breaks_with_maxcolwidths():
485485
]
486486
)
487487
result = tabulate(table, tablefmt="grid", maxcolwidths=10)
488-
assert_equal(result, expected)
488+
assert_equal(expected, result)
489489

490490

491491
def test_exception_on_empty_data_with_maxcolwidths():
@@ -509,6 +509,6 @@ def test_numpy_int64_as_integer():
509509
"| 1 | 3.14 |",
510510
]
511511
)
512-
assert_equal(result, expected)
512+
assert_equal(expected, result)
513513
except ImportError:
514514
raise skip("")

0 commit comments

Comments
 (0)