Some time ago, Sam Ruby wrote:
> Since you asked, my first preference is to avoid dependencies which are 
> not in the standard library.  My second preference is to avoid 
> dependencies which are not available via apt-get in Ubuntu.  The latter 
> brings in json, but does not bring in nose.
> 
> The fact that it is Ubuntu isn't important, it merely is an indirect 
> measure of how common or standard a given module is.  My experience is 
> that the more non-standard and non-common you go, the smaller the 
> development community will be, and the more fragile the module itself 
> will be.
> 
> But if you decide to go for nose, then I would agree, there is no need 
> for UnitTest.

In the light of the recent discussion of the complexity in our testing 
framework[1], I have been revisiting the decision to use UnitTest 
instead of a third-party testing framework. I think that discussion 
makes it clear that the type of data-driven testing that we are using is 
  quite complex and fragile to implement in UnitTest, making it harder 
to identify the code responsible for performing the actual tests and 
more likely that something subtle will break. This pain seem unnecessary 
given that the problem of data-driven testing is solved and there are at 
least two well supported, mature, libraries for python (nose and 
py.test) that do exactly what we want. As it happens, since we last 
discussed this issue the new release of Ubuntu has added a package for 
nose (it turns out that py.test, the other available option, has been in 
  for some time), thus making these fall under Sam's second preference 
above.

The downside of using external libraries is obviously the cost of 
installing them (although in this respect I should point out that we are 
already in a pretty bad way; making changes without testing them in 
ElementTree, lxml and BeautifulSoup is something I would strongly 
discourage). Possibly we could do something with svn:externals or a 
setup.py file to make the process of installing the dependencies easier.

For comparison, here is test_encoding.py implemented for nose (and I 
think it would work identically with py.test):

import os
from support import html5lib_test_files, TestData

#RELEASE remove
import inputstream
#END RELEASE

#RELEASE add
#import html5lib
#from html5lib import inputstream
#END RELEASE

def test_meta():
     for filename in html5lib_test_files("encoding"):
         print filename
         for test in TestData(filename, ("data", "encoding")):
             yield encodingTest, test["data"], test["encoding"]

def encodingTest(data, encoding):
     stream = inputstream.HTMLInputStream(data,chardet=False)
     print "#data\n%s\nExpected:\n%s\nRecieved:\n%s"%(data,
                                                      encoding.lower(),
                                                      stream.charEncoding)
     assert encoding.lower() == stream.charEncoding

def test_chardet():
     try:
         import chardet
         data = open("../../testdata/encoding/chardet/test_big5.txt").read()
         encoding = inputstream.HTMLInputStream(data).charEncoding
         print "#data\n%s\nExpected:\n%s\nRecieved:\n%s"%(data,
                                                          encoding.lower(),
                                                         "big5")
         assert encoding.lower() == "big5"
     except ImportError:
         #This line won't actually print
         print "chardet not found, skipping chardet tests"

(apologies if there are line-wrapping issues). What do people think? Is 
simpler code worth the possible alienation of potential developers who 
have to install an extra module?

[1] http://intertwingly.net/blog/2007/06/04/Python-Pain-Points

-- 
"Instructions to follow very carefully.
Go to Tesco's.  Go to the coffee aisle.  Look at the instant coffee. 
Notice that Kenco now comes in refil packs.  Admire the tray on the 
shelf.  It's exquiste corrugated boxiness. The way how it didn't get 
crushed on its long journey from the factory. Now pick up a refil bag. 
Admire the antioxidant claim.  Gaze in awe at the environmental claims 
written on the back of the refil bag.  Start stroking it gently, its my 
packaging precious, all mine....  Be thankful that Amy has only given 
you the highlights of the reasons why that bag is so brilliant."
-- ajs

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"html5lib-discuss" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.com/group/html5lib-discuss?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to