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

Skip to content

Commit 7929681

Browse files
committed
TST: Add test for reprs
1 parent 4cbcbc2 commit 7929681

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test_cycler.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,25 @@ def test_fail_getime():
123123
c1 = cycler('lw', range(15))
124124
assert_raises(ValueError, Cycler.__getitem__, c1, 0)
125125
assert_raises(ValueError, Cycler.__getitem__, c1, [0, 1])
126+
127+
128+
def _repr_tester_helper(rpr_func, cyc, target_repr):
129+
test_repr = getattr(cyc, rpr_func)()
130+
assert_equal(test_repr, target_repr)
131+
132+
133+
def test_repr():
134+
c = cycler('c', 'rgb')
135+
c2 = cycler('lw', range(3))
136+
137+
c_sum_rpr = "(cycler('c', ['r', 'g', 'b']) + cycler('lw', [0, 1, 2]))"
138+
c_prod_rpr = "(cycler('c', ['r', 'g', 'b']) * cycler('lw', [0, 1, 2]))"
139+
140+
yield _repr_tester_helper, '__repr__', c + c2, c_sum_rpr
141+
yield _repr_tester_helper, '__repr__', c * c2, c_prod_rpr
142+
143+
sum_html = "<table><th>'c'</th><th>'lw'</th><tr><td>'r'</td><td>0</td></tr><tr><td>'g'</td><td>1</td></tr><tr><td>'b'</td><td>2</td></tr></table>"
144+
prod_html = "<table><th>'c'</th><th>'lw'</th><tr><td>'r'</td><td>0</td></tr><tr><td>'r'</td><td>1</td></tr><tr><td>'r'</td><td>2</td></tr><tr><td>'g'</td><td>0</td></tr><tr><td>'g'</td><td>1</td></tr><tr><td>'g'</td><td>2</td></tr><tr><td>'b'</td><td>0</td></tr><tr><td>'b'</td><td>1</td></tr><tr><td>'b'</td><td>2</td></tr></table>"
145+
146+
yield _repr_tester_helper, '_repr_html_', c + c2, sum_html
147+
yield _repr_tester_helper, '_repr_html_', c * c2, prod_html

0 commit comments

Comments
 (0)