[z3-five] Re: Functional doctests for Five

Philipp von Weitershausen philipp at weitershausen.de
Thu Sep 30 11:36:51 MEST 2004


"Stefan H. Holek" wrote:

> On 29.09.2004, at 17:45, Tres Seaver wrote:
> >
> > Note that unless you convert them using the 
> > "docstring-on-an-empty-method" spelling, you will be changing 
> > semantics of the tests:  the "tell-a-story-in-a-text-file" model 
> > deliberated does *not* isolate tests from one another.  This is my 
> > major beef with doctests:  the "isolated" spelling doesn't have the 
> > win that the "story" case does, but the "story" case doesn't (can't) 
> > do as good a job of "test one thing only."
> >
> 
> Are you saying that doctests may "spill over" to subsequent tests?

No. doctests have setUp() and tearDown() just like other tests. However, within 
a doctest file, you test in a story, not in atomic tests, e.g.:

  Booleans represent two states, true and false. In Python, true is
  represented by the `True` variable:

    >>> a = 3
    >>> b = 5
    >>> a < b
    True

  Simlarly, false is represented by `False`:

    >>> b = 2
    >>> a < b
    False

As opposed to:

class BoolTest(TestCase):

  def setUp(self):
      self.a = 3
      self.b = 5

  def test_true(self):
      self.assert_(self.a < self.b)

  def test_false(self):
      self.assert_(self.b > self.a)


> /me senses disturbance in the force, reaches for light saber ....

Keep the mouse in the house, no need to worry. :)

Philipp



More information about the z3-five mailing list