[#7528] set alphabetical HTML attributes for consistent test runs
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 0eaf741..d2922c5 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -23,6 +23,7 @@
from BeautifulSoup import BeautifulSoup
import html5lib
import html5lib.serializer
+import html5lib.filters.alphabeticalattributes
import markdown
from . import macro
@@ -509,7 +510,8 @@
parsed = parser.parse(text)
serializer = html5lib.serializer.HTMLSerializer()
walker = html5lib.getTreeWalker("etree")
- out = ''.join(serializer.serialize(walker(parsed)))
+ stream = html5lib.filters.alphabeticalattributes.Filter(walker(parsed))
+ out = ''.join(serializer.serialize(stream))
return out
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 9681d61..179f19a 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -149,7 +149,7 @@
n = M.Neighborhood.query.get(name='Projects')
r = self.app.get(
'/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True)
- assert '<p><em>aaa</em>bb<a href="/p/test/wiki/Home/" class="alink">[wiki:Home]</a></p>' in r, r
+ assert '<p><em>aaa</em>bb<a class="alink" href="/p/test/wiki/Home">[wiki:Home]</a></p>' in r, r
def test_slash_redirect(self):
self.app.get('/p', status=301)
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 702e037..5dc0e43 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -167,7 +167,7 @@
with h.push_config(c, project=p_test):
r = g.markdown_wiki.convert('[[gittip_button username=test]]')
assert_equal(
- r, u'<div class="markdown_content"><p><iframe width="48pt" height="22pt" style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/test/widget.html"></iframe>\n</p></div>')
+ r, u'<div class="markdown_content"><p><iframe height="22pt" src="https://www.gittip.com/test/widget.html" style="border: 0; margin: 0; padding: 0;" width="48pt"></iframe>\n</p></div>')
def test_macro_neighborhood_feeds():
@@ -325,7 +325,7 @@
}
r = g.markdown_wiki.convert(
'[[embed url=http://www.youtube.com/watch?v=kOLpSPEA72U]]')
- assert_in('<div class="grid-20"><iframe src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" height="270" width="480"></iframe>\n</div>',
+ assert_in('<div class="grid-20"><iframe height="270" src="https://www.youtube.com/embed/kOLpSPEA72U?feature=oembed" width="480"></iframe>\n</div>',
r)
@@ -356,25 +356,25 @@
assert 'See <span>[18:13:49]</span>' in text, text
with h.push_context('test', 'wiki', neighborhood='Projects'):
text = g.markdown.convert('Read [here](Home) about our project')
- assert '<a href="/p/test/wiki/Home/" class="">here</a>' in text, text
+ assert '<a class="" href="/p/test/wiki/Home">here</a>' in text, text
text = g.markdown.convert('[Go home](test:wiki:Home)')
- assert '<a href="/p/test/wiki/Home/" class="">Go home</a>' in text, text
+ assert '<a class="" href="/p/test/wiki/Home">Go home</a>' in text, text
text = g.markdown.convert('See [test:wiki:Home]')
- assert '<a href="/p/test/wiki/Home/" class="alink">[test:wiki:Home]</a>' in text, text
+ assert '<a class="alink" href="/p/test/wiki/Home">[test:wiki:Home]</a>' in text, text
def test_markdown_links():
with patch.dict(tg.config, {'nofollow_exempt_domains': 'foobar.net'}):
text = g.markdown.convert(
'Read [here](http://foobar.net/) about our project')
- assert_in('href="http://foobar.net/" class="">here</a> about', text)
+ assert_in('class="" href="http://foobar.net">here</a> about', text)
text = g.markdown.convert(
'Read [here](http://foobar.net/) about our project')
- assert_in('href="http://foobar.net/" class="" rel="nofollow">here</a> about', text)
+ assert_in('class="" href="http://foobar.net" rel="nofollow">here</a> about', text)
text = g.markdown.convert('Read [here](/p/foobar/blah) about our project')
- assert_in('href="/p/foobar/blah" class="">here</a> about', text)
+ assert_in('class="" href="/p/foobar/blah">here</a> about', text)
text = g.markdown.convert('Read <http://foobar.net/> about our project')
assert_in(
@@ -412,7 +412,7 @@
def test_markdown_basics():
with h.push_context('test', 'wiki', neighborhood='Projects'):
text = g.markdown.convert('# Foo!\n[Home]')
- assert '<a href="/p/test/wiki/Home/" class="alink">[Home]</a>' in text, text
+ assert '<a class="alink" href="/p/test/wiki/Home">[Home]</a>' in text, text
text = g.markdown.convert('# Foo!\n[Rooted]')
assert '<a href=' not in text, text
diff --git a/ForgeBlog/forgeblog/tests/test_commands.py b/ForgeBlog/forgeblog/tests/test_commands.py
index b0cd2b4..7f2d0f7 100644
--- a/ForgeBlog/forgeblog/tests/test_commands.py
+++ b/ForgeBlog/forgeblog/tests/test_commands.py
@@ -149,8 +149,8 @@
html = g.markdown.convert(text)
assert_equal(html,
'<div class="markdown_content"><p>1. foo '
- '#foo bar <a href="../baz" class="">baz</a> foo bar '
- '#foo bar <a href="../baz" class=""> baz </a></p></div>'
+ '#foo bar <a class="" href="../baz">baz</a> foo bar '
+ '#foo bar <a class="" href="../baz"> baz </a></p></div>'
)
@@ -172,6 +172,6 @@
html = g.markdown.convert(text)
assert_equal(html,
'<div class="markdown_content"><p>1. foo</p>\n'
- '<p>#foo bar <a href="../baz" class="">baz</a> foo bar </p>\n'
- '<p>#foo bar <a href="../baz" class=""> baz </a></p></div>'
+ '<p>#foo bar <a class="" href="../baz">baz</a> foo bar </p>\n'
+ '<p>#foo bar <a class="" href="../baz"> baz </a></p></div>'
)
diff --git a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
index 4d0b740..34842c5 100644
--- a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
+++ b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
@@ -132,6 +132,6 @@
'fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
'non proident, sunt in culpa qui officia deserunt mollit '
'anim id est laborum.... '
- '<a href="/p/test/blog/%s/%02i/untitled/" class="">'
+ '<a class="" href="/p/test/blog/%s/%02i/untitled">'
'read more</a></p></div>') % (now.year, now.month)
assert_equal(self._make_post(text).html_text_preview, expected)
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 7c9fffe..890029a 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -891,8 +891,8 @@
assert_not_in('Tickets: <s>#1</s>', r)
assert_in('Tickets: <s>#2</s>', r)
- assert_in('<a href="/p/test/bugs/1/" class="alink">[#1]</a>', r.body)
- assert_in('<a href="/p/test/bugs/2/" class="alink strikethrough">[#2]</a>', r.body)
+ assert_in('<a class="alink" href="/p/test/bugs/1">[#1]</a>', r.body)
+ assert_in('<a class="alink strikethrough" href="/p/test/bugs/2">[#2]</a>', r.body)
def test_ticket_view_editable(self):
summary = 'test ticket view page can be edited'
@@ -2324,7 +2324,7 @@
return_path, rcpts, body = _client.sendmail.call_args[0]
body = body.split('\n')
assert 'Subject: [test:bugs] #1 test <h2> ticket' in body
- assert '<p><strong> <a href="http://localhost/p/test/bugs/1/" class="alink">[bugs:#1]</a> test <h2> ticket</strong></p>' in body
+ assert '<p><strong> <a class="alink" href="http://localhost/p/test/bugs/1">[bugs:#1]</a> test <h2> ticket</strong></p>' in body
@patch('forgetracker.search.query_filter_choices')
def test_multiselect(self, query_filter_choices):