Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #89840

Re: Is this a good way to implement testing

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; '*not*': 0.07; 'doctest': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tests,': 0.09; 'python': 0.11; 'docstrings': 0.16; 'doctests': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'substitute': 0.16; 'code.': 0.18; 'module': 0.19; 'examples': 0.20; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'helpful': 0.24; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'testing': 0.29; 'leave': 0.29; 'errors': 0.30; 'writes:': 0.31; 'text': 0.33; 'reader': 0.33; 'etc.)': 0.35; 'test': 0.35; 'there': 0.35; 'coverage': 0.36; 'module.': 0.36; 'should': 0.36; 'unit': 0.37; 'ben': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:\xe2 10': 0.65; '8bit%:21': 0.69; '8bit%:46': 0.78; 'heavy': 0.81; 'subject:this': 0.83; '*and*': 0.84; 'otten': 0.84; 'received:125': 0.84; 'religion': 0.84; 'subject:good': 0.84; 'usage;': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Is this a good way to implement testing
Date Sun, 03 May 2015 18:52:21 +1000
References <878ud6mx4y.fsf@Equus.decebal.nl> <87383em7sn.fsf@Equus.decebal.nl> <mi4n7a$jb3$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock sha1:ywYDFrZEdvLk04UTraYJ90PyIQE=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.55.1430643305.12865.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430643305 news.xs4all.nl 2962 [2001:888:2000:d::a6]:35645
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:89840

Show key headers only | View raw


Peter Otten <__peter__@web.de> writes:

> Be aware that there is also doctest which scans docstrings for text
> resembling interactive Python sessions. Doctests are both tests and
> usage examples, so I think it's good to put a few of these into the
> module.

Yes, it's definitely a good idea to put some examples into the
docstrings as doctests.

Be aware, though, that this is *not* a substitute for unit tests;
doctest is for testing your documentation, not testing your code.

You should not aim for extensive coverage in doctests. Heavy use of
doctests makes for bad tests *and* bad documentation.

Instead, write only those examples that the reader will find helpful to
understand normal usage; and use the ‘doctest’ module to test that your
documentation is still accurate.

Put all your other broad-coverage tests elsewhere (unit tests, behaviour
tests, etc.) and leave the docstrings readable.

-- 
 \          “Generally speaking, the errors in religion are dangerous; |
  `\    those in philosophy only ridiculous.” —David Hume, _A Treatise |
_o__)                                           of Human Nature_, 1739 |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 00:29 +0200
  Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 00:17 +0100
  Re: Is this a good way to implement testing Terry Reedy <tjreedy@udel.edu> - 2015-05-02 20:06 -0400
  Re: Is this a good way to implement testing Paul Rubin <no.email@nospam.invalid> - 2015-05-02 20:58 -0700
    Re: Is this a good way to implement testing Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 14:49 +1000
  Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 09:36 +0200
    Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 09:38 +0100
    Re: Is this a good way to implement testing Peter Otten <__peter__@web.de> - 2015-05-03 10:45 +0200
      Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 11:49 +0200
        Re: Is this a good way to implement testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-03 11:21 +0100
          Re: Is this a good way to implement testing Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 12:50 +0200
    Re: Is this a good way to implement testing Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 18:52 +1000
  Re: Is this a good way to implement testing Peter Otten <__peter__@web.de> - 2015-05-03 11:22 +0200

csiph-web