Opened 14 years ago
Closed 14 years ago
#17641 closed Bug (fixed)
HTMLParser has no interesting_cdata attribute with a Python version > 2.7.2
| Reported by: | Ramiro Morales | Owned by: | nobody | 
|---|---|---|---|
| Component: | Testing framework | Version: | dev | 
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | yes | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description (last modified by )
Our recent enhancements to the HTML content checking assertions in our test utils subclass and customizes standard library HTMLParser. But in recent HTMLParser shipped with recent 2.7.x CPythons there is no more a interesting_cdata module-level RE variable.
This results in 15 errors in our test suite like this
======================================================================
ERROR: test_readonly_get (regressiontests.admin_views.tests.ReadonlyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/regressiontests/admin_views/tests.py", line 2861, in test_readonly_get
    self.assertContains(response, '<p class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</p>', html=True)
  File "django/test/testcases.py", line 627, in assertContains
    u"Response's content is not valid HTML:")
  File "django/test/testcases.py", line 87, in assert_and_parse_html
    dom = parse_html(html)
  File "django/test/html.py", line 213, in parse_html
    parser.feed(html)
  File "/usr/lib/python2.7/HTMLParser.py", line 111, in feed
    self.goahead(0)
  File "/usr/lib/python2.7/HTMLParser.py", line 155, in goahead
    k = self.parse_starttag(i)
  File "django/utils/htmlparser.py", line 68, in parse_starttag
    self.set_cdata_mode(tag) # <--------------------------- Changed
  File "django/utils/htmlparser.py", line 14, in set_cdata_mode
    self.interesting = _HTMLParser.interesting_cdata
AttributeError: 'module' object has no attribute 'interesting_cdata'
See:
Our CI server is using an older 2.7.x Python.
Attachments (1)
Change History (6)
comment:1 by , 14 years ago
| Description: | modified (diff) | 
|---|---|
| Has patch: | set | 
by , 14 years ago
| Attachment: | 17641-1.diff added | 
|---|
comment:3 by , 14 years ago
Ah I'm running the test on Debian unstable, and now I understand why it reports '2.7.2+' as its version. Most surely it includes fixes post 2.7.2
$ python -c 'import sys ; print("Python version: %s" % sys.version)'
Python version: 2.7.2+ (default, Jan 20 2012, 23:05:38) 
[GCC 4.6.2]
comment:4 by , 14 years ago
| Summary: | HTMLParser has no interesting_cdata attribute with a Python version > 2.7.1 → HTMLParser has no interesting_cdata attribute with a Python version > 2.7.2 | 
|---|
I run the test mentioned in the report on Python 2.7.2 and latest trunk:
(django)lrekucki@blizzard:~/django/django_lqc/tests {master *}$ python --version Python 2.7.2 (django)lrekucki@blizzard:~/django/django_lqc/tests {master *}$ PYTHONPATH=.. python runtests.py --settings=test_sqlite admin_views.ReadonlyTest Creating test database for alias 'default'... Creating test database for alias 'other'... ... ---------------------------------------------------------------------- Ran 3 tests in 1.035s OK Destroying test database for alias 'default'... Destroying test database for alias 'other'...So there must be something else going on.