Tomáš Petříček <[email protected]> added the comment:
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)?
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com