Closed davidtingsu closed 10 years ago
Hi David,
I just got back from vacation. This looks great.
I am having some trouble running the unit tests on my machine. I am getting failures like this:
======================================================================
FAIL: test_class_with_dot_and_hash (tests.HtmlToHamlPyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/bosco/Projects/archive/tohaml/tests.py", line 16, in test_class_with_dot_and_hash
self.assertEqual('%div{class:"foo.bar"}', render("<div class=' foo.bar '></div>"))
AssertionError: '%div{class:"foo.bar"}' != u'%html\n %body\n %div{class:"foo.bar"}'
It appears my version of BeautifulSoup inserts <html>
and <body>
tags into the test string.
Do you see this on your system?
I'm using the most recent version of BeautifulSoup installed with pip. beautifulsoup4 4.3.2
I double-checked my version of bs4, it's also 4.3.2.
In the python repl, what does this give you?
import bs4
bs4.BeautifulSoup('<div>')
on my system, I get:
<html><body><div></div></body></html>
What do you get?
(tohamlenv2)➜ tohaml git:(extend-bs4) ✗ python
Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bs4
>>> bs4.BeautifulSoup('<div>')
<div></div>
>>>
Figured it out.
I had installed the recommended lxml
library, which adds the extra tags
for me.
You are using the default (and slower) built-in html.parser
.
On Thu, Jul 24, 2014 at 1:59 PM, davidtingsu notifications@github.com wrote:
(tohamlenv2)➜ tohaml git:(extend-bs4) ✗ pythonPython 2.7.5 (default, Sep 12 2013, 21:33:34)[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import bs4>>> bs4.BeautifulSoup('
')>>>— Reply to this email directly or view it on GitHub https://github.com/boscoh/tohaml/pull/3#issuecomment-49965177.
add some tests based off of https://github.com/haml/html2haml/blob/master/test/html2haml_test.rb fixed some edge cases for classes and ids.