[Python-ideas] Re: Add @parametrize decorator to unittest library

2021-09-06 Thread Guido van Rossum
On Mon, Sep 6, 2021 at 21:45 Christopher Barker wrote: > Just use pytest. > For third party code I agree, it’s the way to go. —Guido -- --Guido (mobile) ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Add @parametrize decorator to unittest library

2021-09-06 Thread Christopher Barker
I believe he is looking for something like pytest’s parameterize: https://docs.pytest.org/en/6.2.x/example/parametrize.html This is actually pretty basic functionality for writing DRY tests, a key missing feature. Frankly though, unittest is painfully unpythonic and hard to extend. I’ve given

[Python-ideas] Re: Add @parametrize decorator to unittest library

2021-09-06 Thread Steven D'Aprano
Hi Leonardo, On Tue, Sep 07, 2021 at 02:31:26AM -, Leonardo Freua wrote: > When writing some unit tests with the standard Unittest library, I > missed being able to create parameterized tests. Could you please explain what you mean by "parameterized tests", and how you would use a

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread Greg Ewing
On 7/09/21 5:46 am, C. Titus Brown via Python-ideas wrote: Maybe Greg missed that DictReader.open didn’t exist and was in fact what I was asking for! Sorry about that, I thought you were asking for context manager methods to be added to an existing file-like object. If csv.DictReader had a

[Python-ideas] Add @parametrize decorator to unittest library

2021-09-06 Thread Leonardo Freua
When writing some unit tests with the standard Unittest library, I missed being able to create parameterized tests. This functionality exists in PyTest (https://docs.pytest.org/en/6.2.x/parametrize.html) and there is also a library called

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread Brendan Barnwell
On 2021-09-06 10:50, Christopher Barker wrote: I think the point here is not the context manager, but rather, having the reader open the file itself, rather than taking an already open file-like object. I agree, and I think having such capability is very useful. I'm always annoyed by things

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread Thomas Grainger
I really like json.loadf I'd also like to see a csv.loadf. not sure the `f` is needed: you could use @functools.singledispatch On Mon, 6 Sep 2021, 01:12 Christopher Barker, wrote: > On Sun, Sep 5, 2021 at 10:32 AM David Mertz, Ph.D. > wrote: > >> Most Pandas read methods take either a

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread Christopher Barker
I think the point here is not the context manager, but rather, having the reader open the file itself, rather than taking an already open file-like object. And if it’s going to do that, it should provide. Context manager. Personally, while we are at it, I’d like to see a “read all” method,

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread C. Titus Brown via Python-ideas
Thanks for your comments, everyone! Right, I’m struggling to figure out Greg's example :). Maybe Greg missed that DictReader.open didn’t exist and was in fact what I was asking for! (contextlib.closing is great, thank you for that!) Anyway, just to re-up the original points and add a few - *

[Python-ideas] Re: Improve traceback for common `with` statement mistake

2021-09-06 Thread Serhiy Storchaka
06.09.21 18:42, Chris Angelico пише: > On Tue, Sep 7, 2021 at 1:36 AM Finn Mason wrote: >> Thank you for testing that. I dug through the change log, and found >> bpo-12022: >> https://bugs.python.org/issue12022 >> It has been fixed in 3.11, but not mentioned in the What's New document. >>

[Python-ideas] Re: Improve traceback for common `with` statement mistake

2021-09-06 Thread Chris Angelico
On Tue, Sep 7, 2021 at 1:36 AM Finn Mason wrote: > > Thank you for testing that. I dug through the change log, and found bpo-12022: > https://bugs.python.org/issue12022 > It has been fixed in 3.11, but not mentioned in the What's New document. > Should it be? > If it was indeed a side effect of

[Python-ideas] Re: Improve traceback for common `with` statement mistake

2021-09-06 Thread Finn Mason
Thank you for testing that. I dug through the change log, and found bpo-12022: https://bugs.python.org/issue12022 It *has* been fixed in 3.11, but not mentioned in the What's New document. Should it be? On Sun, Sep 5, 2021, 5:49 PM Chris Angelico wrote: > On Mon, Sep 6, 2021 at 9:37 AM Finn