|
7 | 7 |
|
8 | 8 | import django_tables2 as tables
|
9 | 9 | from django_tables2 import A
|
10 |
| -from django_tables2.utils import AttributeDict |
11 | 10 |
|
12 | 11 | from ..app.models import Occupation, Person
|
13 | 12 | from ..utils import attrs, build_request
|
@@ -158,21 +157,17 @@ class Table(tables.Table):
|
158 | 157 |
|
159 | 158 | table = Table(Person.objects.all())
|
160 | 159 |
|
161 |
| - attrs = AttributeDict({ |
162 |
| - 'href': reverse('person', args=(person.pk, )), |
163 |
| - 'style': 'color: red;' |
164 |
| - }) |
165 |
| - expected = '<a {}>{}</a>'.format(attrs.as_html(), person.first_name) |
166 |
| - assert table.rows[0].get_cell('first_name') == expected |
| 160 | + a_tag = table.rows[0].get_cell('first_name') |
| 161 | + assert 'href="{}"'.format(reverse('person', args=(person.pk, ))) in a_tag |
| 162 | + assert 'style="color: red;"' in a_tag |
| 163 | + assert person.first_name in a_tag |
167 | 164 |
|
168 | 165 | html = table.as_html(build_request())
|
169 |
| - assert expected in html |
170 | 166 |
|
171 |
| - attrs = AttributeDict({ |
172 |
| - 'style': 'background-color: #ddd;', |
173 |
| - 'class': 'first_name' |
174 |
| - }) |
175 |
| - assert '<td {}>'.format(attrs.as_html()) in html |
| 167 | + td_tag_1 = '<td style="background-color: #ddd;" class="first_name">' |
| 168 | + td_tag_2 = '<td class="first_name" style="background-color: #ddd;">' |
| 169 | + |
| 170 | + assert td_tag_1 in html or td_tag_2 in html |
176 | 171 |
|
177 | 172 |
|
178 | 173 | def test_defaults():
|
|
0 commit comments