[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Although that functionality is already easily handled; for example, here's the OP's first example rewritten to be independent of the dict's representation ordering: > >>> dict_fun() == {'foo': 1, 'bar': 2} > > True Oh, right. I remember the headache caus

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Tim Peters
Tim Peters added the comment: Tomáš, of course you can combine testing methods any way you like. Don't oversell this - there's nothing actually magical about comparing objects instead of strings ;-) I'm only -0 on this. It grates a bit against doctest's original intents, but I appreciate i

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Tomáš, thank you for the suggestion, but we're going to decline for the reasons mentioned elsewhere in this thread. That said, it would be perfectly reasonable to post your own variant or extension on PyPI ( http://pypi.python.org ) to test the waters, to

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Tomáš Petříček
Tomáš Petříček 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

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Tim Peters
Tim Peters added the comment: `doctest` is intended to be anal - 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. "Is it a bug? Did I do it wrong? Why can't they document what it actually d

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Raymond. Doctest should test the representation, not value. But I think it would be nice to support insignificant variations of the representation. Tracebacks already are treated specially, and different doctest options allow to ignore particu

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: I recommend not going down this path. The intended purpose of doctest is to test examples in documentation. In particular, those examples should match what a user would *see* when running the examples. In essence, the proposal is to allow tests to pass

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +tim.peters ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-19 Thread Jesse Bakker
Jesse Bakker added the comment: I think this would allow for inconsistency in docs (if implemented as suggested), as when actually running the code in the docs, one would get different results than suggested by the docs. Maybe there is some other way (with different docs syntax) that would wo

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-15 Thread R. David Murray
R. David Murray added the comment: I think it is an interesting idea. Let see what other people think. -- nosy: +r.david.murray ___ Python tracker ___

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-15 Thread Tomáš Petříček
Tomáš Petříček added the comment: The following tests then succeed: def str_fun(): """ >>> str_fun() 'foo' >>> str_fun() "foo" >>> str_fun() '''foo''' """ return 'foo' def dict_fun(): """ >>> dict_fun() {'foo': 1, 'bar': 2} >>> dict_fun()

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-15 Thread Tomáš Petříček
Tomáš Petříček added the comment: This option can be seen as a more general case of the options already available which lift the requirement of exact representation match (True for 1, normalize whitespace etc.). It would enable easier testing of relevant behavior instead of repr's artifacts.

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-15 Thread Tomáš Petříček
Tomáš Petříček added the comment: Related to https://bugs.python.org/issue3332 -- ___ Python tracker ___ ___ Python-bugs-list mailin

[issue32042] Option for comparing values instead of reprs in doctest

2017-11-15 Thread Tomáš Petříček
New submission from Tomáš Petříček : Would there be an interest and possibility to add an option to the doctest module to compare values instead of reprs? The idea is that the expected value would be eval'ed prior to comparison if this option was enabled. Motivation for this option is to enabl