[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2021-05-18 Thread Catherine Devlin


Catherine Devlin  added the comment:

I think that it's possible to get the desired behavior by setting a filter to 
"always".

```
> cat warnme.py 
import warnings

for i in range(3):
warnings.warn("oh noes!")

> python warnme.py 
warnme.py:4: UserWarning: oh noes!
warnings.warn("oh noes!")

> cat warnme2.py 
import warnings

warnings.simplefilter("always")
for i in range(3):
warnings.warn("oh noes!")

> python warnme2.py 
warnme2.py:5: UserWarning: oh noes!
warnings.warn("oh noes!")
warnme2.py:5: UserWarning: oh noes!
warnings.warn("oh noes!")
warnme2.py:5: UserWarning: oh noes!
warnings.warn("oh noes!")
```

Does that meet the need?

--
nosy: +Catherine.Devlin

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2021-01-11 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
superseder:  -> warnings module offers no documented, programmatic way to reset 
"seen-warning" flag

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2020-03-18 Thread Brett Cannon


Change by Brett Cannon :


--
nosy:  -brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2014-01-10 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage:  -> test needed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2014-01-05 Thread R. David Murray

R. David Murray added the comment:

The easy answer for unittest is to use assertWarns.  For versions where that 
doesn't exist you could implement the same technique yourself.  Exposing a 
'clear everything' function in the warnings module might not be a bad idea, but 
otherwise for doctest I'd think the catch_warnings context manager would be the 
correct answer, and that is documented.

Given the above, I guess this issue is a request to expose a "clear everything" 
function in the warnings module, which I think is a reasonable idea.

(I think it would be nice to add some support stuff to doctest to make things 
like this easier, but that is a totally separate issue.)

--
nosy: +brett.cannon, r.david.murray
versions: +Python 3.5 -Python 2.7, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2014-01-05 Thread Andreas Kloeckner

New submission from Andreas Kloeckner:

For tests and doctests, it is often desirable to show or verify that a certain 
warning occurs. Unfortunately, if the warning has been hit previously, it will 
not be issued again. It would be great if there were a documented, unified way 
to reset this 'seen' flag.

Related stackoverflow posts showing that I'm not the first person to have this 
need:

* 
https://stackoverflow.com/questions/19428761/python-showing-once-warnings-again-resetting-all-warning-registries
* https://stackoverflow.com/questions/2418570/testing-warnings-with-doctest

Neither of these has a satisfactory solution.

--
components: Library (Lib)
messages: 207372
nosy: inducer
priority: normal
severity: normal
status: open
title: warnings module offers no documented, programmatic way to reset 
"seen-warning" flag
versions: Python 2.7, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20131] warnings module offers no documented, programmatic way to reset "seen-warning" flag

2014-01-05 Thread Andreas Kloeckner

Changes by Andreas Kloeckner :


--
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com