On Sat, 20 Mar 2010 06:23:14 +0000, Steven D'Aprano wrote: > Are there any guidelines for writing tests for the standard library and > language? I've googled, but found nothing useful: lots of guidelines for > writing tests, and of course I've read PEP 8, but I'm not sure if there > are conventions for tests I'm missing.
I've found this: http://docs.python.org/library/test.html and I've written a small test: $ cat test_unicode_interpolation.py # For testing http://bugs.python.org/issue8128 import test.test_support import unittest class K(unicode): def __str__(self): return "Surprise!" class UnicodeInterpolationTest(unittest.TestCase): def test_interpolation(self): self.assertEquals(u'%s' % K('some text'), 'Surprise!') def test_main(): test.test_support.run_unittest(UnicodeInterpolationTest) if __name__ == "__main__": test_main() but when I try running the test, I get an error: $ python test_unicode_interpolation.py Options: {'delimiter': None} str of options.delimiter = None repr of options.delimiter = None len of options.delimiter Traceback (most recent call last): File "test_unicode_interpolation.py", line 3, in <module> import test.test_support File "/home/steve/python/test.py", line 8, in <module> print "len of options.delimiter", len(options.delimiter) TypeError: object of type 'NoneType' has no len() What am I doing wrong? (By the way, I'm expecting the unit test above to fail.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list