Re: Using pytest, sometimes does not capture stderr

2021-04-05 Thread Peter Otten
On 05/04/2021 06:25, Cameron Simpson wrote: If you truly need to test msg() _without_ the file= parameter, you could monkey patch module_2: old_MSG_DESTINATION = module_2.MSG_DESTINATION module_2.MSG_DESTINATION = sys.stderr # now the module_2 module has an updated reference for

Re: Using pytest, sometimes does not capture stderr

2021-04-04 Thread David
On Mon, 5 Apr 2021 at 14:26, Cameron Simpson wrote: > On 05Apr2021 13:56, David wrote: > >Thanks for confirming my suspicions so quickly. What you wrote > >makes sense, but there are two points that still puzzle me. > >1) The final line of the pytest failure output seems to shows that > >pyt

Re: Using pytest, sometimes does not capture stderr

2021-04-04 Thread Cameron Simpson
On 05Apr2021 13:56, David wrote: >On Mon, 5 Apr 2021 at 13:44, Cameron Simpson wrote: >> On 05Apr2021 13:28, David wrote: >> >Can anyone explain why the module_2.py test fails? >> >Is it because stderr during module import is not the same as during test? >> >Is it something to do with mutable de

Re: Using pytest, sometimes does not capture stderr

2021-04-04 Thread David
On Mon, 5 Apr 2021 at 13:44, Cameron Simpson wrote: > On 05Apr2021 13:28, David wrote: > >Can anyone explain why the module_2.py test fails? > >Is it because stderr during module import is not the same as during test? > >Is it something to do with mutable defaults? > >How to investigate this? >

Re: Using pytest, sometimes does not capture stderr

2021-04-04 Thread Cameron Simpson
On 05Apr2021 13:28, David wrote: >I have just begun using pytest at a basic level and I am >seeing behaviour that I do not understand. > >My platform is Debian 10.9 > >There are 3 files involved, contents are provided below, and attached. >- module_1.py passes the test as expected >- module_2.py h

Using pytest, sometimes does not capture stderr

2021-04-04 Thread David
Hi, I have just begun using pytest at a basic level and I am seeing behaviour that I do not understand. My platform is Debian 10.9 There are 3 files involved, contents are provided below, and attached. - module_1.py passes the test as expected - module_2.py has a tiny change, and fails unexpecte