Merged revisions 82757-82758,82760-82764 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82757 | georg.brandl | 2010-07-10 10:58:37 +0200 (Sa, 10 Jul 2010) | 1 line Fix markup. ........ r82758 | georg.brandl | 2010-07-10 12:23:40 +0200 (Sa, 10 Jul 2010) | 1 line Emphasize role of count for Pascal string. ........ r82760 | georg.brandl | 2010-07-10 12:39:57 +0200 (Sa, 10 Jul 2010) | 1 line #3214: improve description of duck-typing in glossary. ........ r82761 | georg.brandl | 2010-07-10 13:40:13 +0200 (Sa, 10 Jul 2010) | 1 line #1434090: properly append child in expatbuilder doctype handler. ........ r82762 | georg.brandl | 2010-07-10 13:51:06 +0200 (Sa, 10 Jul 2010) | 1 line #8338: fix outdated class name. ........ r82763 | georg.brandl | 2010-07-10 14:01:34 +0200 (Sa, 10 Jul 2010) | 1 line #8456: fix signature of sqlite3.connect(). ........ r82764 | georg.brandl | 2010-07-10 14:20:38 +0200 (Sa, 10 Jul 2010) | 1 line #8564: update docs on integrating doctest/unittest with unittest(2) test discovery. ........
This commit is contained in:
parent
41b986c352
commit
e85e1ae413
|
@ -156,9 +156,9 @@ Glossary
|
||||||
object.
|
object.
|
||||||
|
|
||||||
duck-typing
|
duck-typing
|
||||||
A pythonic programming style which determines an object's type by inspection
|
A programming style which does not look at an object's type to determine
|
||||||
of its method or attribute signature rather than by explicit relationship
|
if it has the right interface; instead, the method or attribute is simply
|
||||||
to some type object ("If it looks like a duck and quacks like a duck, it
|
called or used ("If it looks like a duck and quacks like a duck, it
|
||||||
must be a duck.") By emphasizing interfaces rather than specific types,
|
must be a duck.") By emphasizing interfaces rather than specific types,
|
||||||
well-designed code improves its flexibility by allowing polymorphic
|
well-designed code improves its flexibility by allowing polymorphic
|
||||||
substitution. Duck-typing avoids tests using :func:`type` or
|
substitution. Duck-typing avoids tests using :func:`type` or
|
||||||
|
|
|
@ -972,18 +972,17 @@ serious Python testing frameworks build on the :mod:`unittest` module, which
|
||||||
supplies many flexible ways to combine tests from multiple sources. So, in
|
supplies many flexible ways to combine tests from multiple sources. So, in
|
||||||
Python 2.4, :mod:`doctest`'s :class:`Tester` class is deprecated, and
|
Python 2.4, :mod:`doctest`'s :class:`Tester` class is deprecated, and
|
||||||
:mod:`doctest` provides two functions that can be used to create :mod:`unittest`
|
:mod:`doctest` provides two functions that can be used to create :mod:`unittest`
|
||||||
test suites from modules and text files containing doctests. These test suites
|
test suites from modules and text files containing doctests. To integrate with
|
||||||
can then be run using :mod:`unittest` test runners::
|
:mod:`unittest` test discovery, include a :func:`load_tests` function in your
|
||||||
|
test module::
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import doctest
|
import doctest
|
||||||
import my_module_with_doctests, and_another
|
import my_module_with_doctests
|
||||||
|
|
||||||
suite = unittest.TestSuite()
|
def load_tests(loader, tests, ignore):
|
||||||
for mod in my_module_with_doctests, and_another:
|
tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
|
||||||
suite.addTest(doctest.DocTestSuite(mod))
|
return test
|
||||||
runner = unittest.TextTestRunner()
|
|
||||||
runner.run(suite)
|
|
||||||
|
|
||||||
There are two main functions for creating :class:`unittest.TestSuite` instances
|
There are two main functions for creating :class:`unittest.TestSuite` instances
|
||||||
from text files and modules with doctests:
|
from text files and modules with doctests:
|
||||||
|
|
|
@ -138,7 +138,7 @@ Module functions and constants
|
||||||
first blank for the column name: the column name would simply be "x".
|
first blank for the column name: the column name would simply be "x".
|
||||||
|
|
||||||
|
|
||||||
.. function:: connect(database[, timeout, isolation_level, detect_types, factory])
|
.. function:: connect(database[, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements])
|
||||||
|
|
||||||
Opens a connection to the SQLite database file *database*. You can use
|
Opens a connection to the SQLite database file *database*. You can use
|
||||||
``":memory:"`` to open a database connection to a database that resides in RAM
|
``":memory:"`` to open a database connection to a database that resides in RAM
|
||||||
|
|
|
@ -263,14 +263,14 @@ specified number of bytes. As a special case, ``'0s'`` means a single, empty
|
||||||
string (while ``'0c'`` means 0 characters).
|
string (while ``'0c'`` means 0 characters).
|
||||||
|
|
||||||
The ``'p'`` format character encodes a "Pascal string", meaning a short
|
The ``'p'`` format character encodes a "Pascal string", meaning a short
|
||||||
variable-length string stored in a fixed number of bytes. The count is the total
|
variable-length string stored in a *fixed number of bytes*, given by the count.
|
||||||
number of bytes stored. The first byte stored is the length of the string, or
|
The first byte stored is the length of the string, or 255, whichever is smaller.
|
||||||
255, whichever is smaller. The bytes of the string follow. If the string
|
The bytes of the string follow. If the string passed in to :func:`pack` is too
|
||||||
passed in to :func:`pack` is too long (longer than the count minus 1), only the
|
long (longer than the count minus 1), only the leading ``count-1`` bytes of the
|
||||||
leading count-1 bytes of the string are stored. If the string is shorter than
|
string are stored. If the string is shorter than ``count-1``, it is padded with
|
||||||
count-1, it is padded with null bytes so that exactly count bytes in all are
|
null bytes so that exactly count bytes in all are used. Note that for
|
||||||
used. Note that for :func:`unpack`, the ``'p'`` format character consumes count
|
:func:`unpack`, the ``'p'`` format character consumes count bytes, but that the
|
||||||
bytes, but that the string returned can never contain more than 255 characters.
|
string returned can never contain more than 255 characters.
|
||||||
|
|
||||||
For the ``'P'`` format character, the return value is a Python integer or long
|
For the ``'P'`` format character, the return value is a Python integer or long
|
||||||
integer, depending on the size needed to hold a pointer when it has been cast to
|
integer, depending on the size needed to hold a pointer when it has been cast to
|
||||||
|
|
|
@ -242,7 +242,7 @@ class ExpatBuilder:
|
||||||
doctype = self.document.implementation.createDocumentType(
|
doctype = self.document.implementation.createDocumentType(
|
||||||
doctypeName, publicId, systemId)
|
doctypeName, publicId, systemId)
|
||||||
doctype.ownerDocument = self.document
|
doctype.ownerDocument = self.document
|
||||||
self.document.childNodes.append(doctype)
|
_append_child(self.document, doctype)
|
||||||
self.document.doctype = doctype
|
self.document.doctype = doctype
|
||||||
if self._filter and self._filter.acceptNode(doctype) == FILTER_REJECT:
|
if self._filter and self._filter.acceptNode(doctype) == FILTER_REJECT:
|
||||||
self.document.doctype = None
|
self.document.doctype = None
|
||||||
|
|
Loading…
Reference in New Issue