Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'warnings': 0.04; 'reject': 0.07; 'converted': 0.09; 'doctest': 0.09; 'elegant,': 0.09; 'friday,': 0.09; 'subject:skip:c 10': 0.09; 'testing,': 0.09; 'unittest': 0.09; 'python': 0.11; 'missed': 0.12; '2.7': 0.14; 'changes': 0.15; '.py': 0.16; '.txt': 0.16; 'boring,': 0.16; 'cases)': 0.16; 'doctests': 0.16; 'outcomes': 0.16; 'reedy': 0.16; 'stuff.': 0.16; 'subject:python': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'meant': 0.20; '(in': 0.22; 'certainly': 0.24; 'char': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'tried': 0.27; 'idea': 0.28; 'testing': 0.29; 'skip:- 40': 0.29; 'am,': 0.29; 'code': 0.31; '(maybe': 0.31; 'option.': 0.31; 'file': 0.32; 'url:python': 0.33; 'cases': 0.33; 'fri,': 0.33; 'header:Received:9': 0.33; 'date:': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'edge': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'january': 0.37; 'unit': 0.37; 'too': 0.37; 'email addr:python.org': 0.37; 'e.g.': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'received:98.137': 0.60; 're:': 0.63; 'more': 0.64; 'email name :python-list': 0.65; 'url:0': 0.67; 'subject: & ': 0.68; "'true'": 0.84; '2014,': 0.84; "they'd": 0.84; 'dozen': 0.91; 'received:98.138.226': 0.93 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 428387.45639.bm@omp1098.mail.gq1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1390034365; bh=rrHeCDOK4WQoFVwGy/osFHvHTfAkXhP/DfNjyKT3mx4=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=loaSv7K9o7PFMzq84tGenIT7Bgx+WdDSInrhtZB0U8QymFOsyUTX+7sjpmM4ZH4k1hcYfCjy15X14JmVWDj5gnw0GAX46cgQhcugTm3wxHsEVa4lWoaPmxL3dBOs8P2N5AeOZoV70jKyNTqXmGXQEH02biOH7pQI8AlsZ9pqMR0= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=2HVcbUrJE5EnnsZ3m151LaqxSI6icD3Yja9t4/qy2BqCiNFNLv5DF3uQ+jS/urdhgLGLetb9I5wUZKjIfmgQ1SQcmROdh661TLyLdPTx2RsDcqH+hziw4KiEqaylYDSz85wB6lRSjWLrfKtT9btyJTJ64GyXXPzshyjO20gxxZQ=; X-YMail-OSG: Tf4aWiIVM1kS7hpaTL7RTa6whf8sl_pLqUVIq5O0QRc.17D KAVNafCmD1Qctila27i4e.wO_P0JDeZ0hW45Tt8UgHmND5ALo.reOoosR2pk olyAXhBMuH1CFYQQCHcZDI0aY5Hpizj56pbV8Je55NIg98dvgbf5G7fJFpkp AFkn3FK7F0odwFNLr8VN3TKMidm.XCmzoS1.BL4mPAgUKfroB5UwTHXwe8Xf YgHyMl1ZQr08xkqSQRMEw4mSZ8nr8OVhkb.tTU4qnCpYWU5iIg.nLVwYm6Dq nKz6exC.3P9oEQ4_TTR0VNMg1odCK1smllSe7nmgkvYHre6.YW.JrsTQh4MV 9DdgBH.DhvJzIlHVAOWfjICBrOs97odQOhvibi_tMgZtSdTZFPFQG3mI9aS7 mYe6c6L3_MGSUr1grVM08MkcN8s4wMQjFFVEBw30ZerQlU2C_9rgFIncaCPf xje8FKk1lHQOQKVvNhSqiNnjJBsSkr4rthxhbvrJvMHn13dTjk0l9Xt3Fh3s eqdktPax5GhpbxjkCeLcHqdnMB0cTDb7YdGj_8IqZnca6LucPLqG2Lzi5iJb p4FaffjULv13vGwqDgA-- X-Rocket-MIMEInfo: 002.001, LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCk9uIEZyaSwgMS8xNy8xNCwgVGVycnkgUmVlZHkgPHRqcmVlZHlAdWRlbC5lZHU.IHdyb3RlOg0KDQogU3ViamVjdDogUmU6IGRvY3Rlc3RzIGNvbXBhdGliaWxpdHkgZm9yIHB5dGhvbiAyICYgcHl0aG9uIDMNCiBUbzogcHl0aG9uLWxpc3RAcHl0aG9uLm9yZw0KIERhdGU6IEZyaWRheSwgSmFudWFyeSAxNywgMjAxNCwgMTA6MTAgUE0NCiANCiBPbiAxLzE3LzIwMTQgNzoxNCBBTSwgUm9iaW4gQmVja2VyDQogd3JvdGU6DQogDQoBMAEBAQE- X-Mailer: YahooMailClassic/390 YahooMailWebService/0.8.173.622 Date: Sat, 18 Jan 2014 00:39:25 -0800 (PST) From: Albert-Jan Roskam Subject: Re: doctests compatibility for python 2 & python 3 To: python-list@python.org, Terry Reedy In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390034547 news.xs4all.nl 2902 [2001:888:2000:d::a6]:56384 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64219 -------------------------------------------- On Fri, 1/17/14, Terry Reedy wrote: Subject: Re: doctests compatibility for python 2 & python 3 To: python-list@python.org Date: Friday, January 17, 2014, 10:10 PM On 1/17/2014 7:14 AM, Robin Becker wrote: > I tried this approach with a few more complicated outcomes and they fail > in python2 or 3 depending on how I try to render the result in the doctest. I never got how you are using doctests. There were certainly not meant for heavy-duty unit testing, but for testing combined with explanation. Section 26.2.3.7. (in 3.3) Warnings warns that they are fragile to even single char changes and suggests == as a workaround, as 'True' and 'False' will not change. So I would not reject that option. =====> I used doctests in .txt files and I converted ALL of them when I wanted to make my code work for both Python 2 and 3. I tried to fix something like a dozen of them so they'd work in Python 2.7 and 3,3. but I found it just too cumbersome and time consuming. The idea of doctest is super elegant, but it is really only meant for testable documentation (maybe with sphinx). If you'd put all the (often boring, e.g. edge cases) test cases in docstrings, the .py file will look very cluttered. One thing that I missed in unittest was Ellipsis, but: https://pypi.python.org/pypi/gocept.testing/1.6.0 offers assertEllipsis and other useful stuff. Albert-Jan