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

Skip to content

Commit 369a8f8

Browse files
committed
Even more determinism for attributes in LinkColumn test
1 parent a59b530 commit 369a8f8

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

tests/columns/test_linkcolumn.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import django_tables2 as tables
99
from django_tables2 import A
10-
from django_tables2.utils import AttributeDict
1110

1211
from ..app.models import Occupation, Person
1312
from ..utils import attrs, build_request
@@ -158,21 +157,17 @@ class Table(tables.Table):
158157

159158
table = Table(Person.objects.all())
160159

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
167164

168165
html = table.as_html(build_request())
169-
assert expected in html
170166

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
176171

177172

178173
def test_defaults():

0 commit comments

Comments
 (0)