← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1273943] [NEW] Tox failing on py27dj14 environment

 

Public bug reported:

Full test log: http://paste.openstack.org/show/62066/

It seems like django.test.assertContain is unable to parse template
html.

Further inspection revealed that there is a difference in parsing
between start tag and end tag and even more, difference between parsing
tags with and without the attributes:

HTMLParser.tagfind.match('<script>document.write("something")</script>',
1).end() would result in 7, so the parsed tag will be 'script'

but

HTMLParser.tagfind.match('<script
type="text/javascript">document.write("something")</script>', 1).end()
will result in 8 and a parsed tag of 'script ' (with tailing whitespace)

Somewhere between 2.7.3 and 2.7.4 Python had changed its
HTMLParser.tagfind regex [1, 2]. Django relied heavily on this regex
with its own _HtmlParser modification [3] and hadn't react fast enough
to land the fix in 1.4 [4].

So what we are having here is for particular configuration including
both python 2.7.4+ and django 1.4, django.test.assertContain would not
be able to properly parse perfectly valid html and would fail this
tests.

The question is what should we do in this case. Should we limit py27dj14
environment with basepython of 2.7.3, should we disable this tests on
Django 1.4, replace the assertion function with one without the bug or
just completely ignore that bug as irrelevant?

---

[1] http://hg.python.org/cpython/file/70274d53c1dd/Lib/HTMLParser.py#l25
[2] http://hg.python.org/cpython/file/026ee0057e2d/Lib/HTMLParser.py#l25
[3] https://github.com/django/django/blob/98a1e14e093211f15e91daa4c9de0402be5d31b8/django/utils/html_parser.py#L36-L39
[4] https://github.com/django/django/commit/6bc1b222994301782bd80780bdeec8c4eb44631a

** Affects: horizon
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1273943

Title:
  Tox failing on py27dj14 environment

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  Full test log: http://paste.openstack.org/show/62066/

  It seems like django.test.assertContain is unable to parse template
  html.

  Further inspection revealed that there is a difference in parsing
  between start tag and end tag and even more, difference between
  parsing tags with and without the attributes:

  HTMLParser.tagfind.match('<script>document.write("something")</script>',
  1).end() would result in 7, so the parsed tag will be 'script'

  but

  HTMLParser.tagfind.match('<script
  type="text/javascript">document.write("something")</script>', 1).end()
  will result in 8 and a parsed tag of 'script ' (with tailing
  whitespace)

  Somewhere between 2.7.3 and 2.7.4 Python had changed its
  HTMLParser.tagfind regex [1, 2]. Django relied heavily on this regex
  with its own _HtmlParser modification [3] and hadn't react fast enough
  to land the fix in 1.4 [4].

  So what we are having here is for particular configuration including
  both python 2.7.4+ and django 1.4, django.test.assertContain would not
  be able to properly parse perfectly valid html and would fail this
  tests.

  The question is what should we do in this case. Should we limit
  py27dj14 environment with basepython of 2.7.3, should we disable this
  tests on Django 1.4, replace the assertion function with one without
  the bug or just completely ignore that bug as irrelevant?

  ---

  [1] http://hg.python.org/cpython/file/70274d53c1dd/Lib/HTMLParser.py#l25
  [2] http://hg.python.org/cpython/file/026ee0057e2d/Lib/HTMLParser.py#l25
  [3] https://github.com/django/django/blob/98a1e14e093211f15e91daa4c9de0402be5d31b8/django/utils/html_parser.py#L36-L39
  [4] https://github.com/django/django/commit/6bc1b222994301782bd80780bdeec8c4eb44631a

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1273943/+subscriptions


Follow ups

References