This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Tomáš Petříček
Recipients Tomáš Petříček, jbakker, r.david.murray, rhettinger, serhiy.storchaka, tim.peters
Date 2017-11-19.20:27:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511123241.02.0.213398074469.issue32042@psf.upfronthosting.co.za>
In-reply-to
Content
I find the idea of combining documentation with examples and unit testing appealing.
I see that this was not the original purpose of doctest but it seems to me as a reasonable use case for doctest.

>>> dict_fun() == {'foo': 1, 'bar': 2}
True
Testing equality with single expression has the drawback that one cannot see what was wrong, i.e., what the actual value was.
The result of such a test when it fails is very uninformative.

I am not sure that I know any Python developer who would be confused by "string" matching 'string', or {'a': 1, 'b': 2} matching dict(a=1, b=2).
Why True matching 1 is less confusing than "abc" matching 'abc'?

"there are few things more pointlessly confusing for a user than to see docs that don't match what they actually see when they run the doc's examples"
This is a bit tricky because what user actually sees very much depends on what console is used to run these examples, e.g., it varies between python and ipython, python and python3 etc.
So the users will be confused by these variants anyway.
Is it actually defined for basic types like str, dict or set, how the repr should look like (besides that it should be possible to "eval" the expression to get value)?
History
Date User Action Args
2017-11-19 20:27:21Tomáš Petříčeksetrecipients: + Tomáš Petříček, tim.peters, rhettinger, r.david.murray, serhiy.storchaka, jbakker
2017-11-19 20:27:21Tomáš Petříčeksetmessageid: <1511123241.02.0.213398074469.issue32042@psf.upfronthosting.co.za>
2017-11-19 20:27:21Tomáš Petříčeklinkissue32042 messages
2017-11-19 20:27:20Tomáš Petříčekcreate