Hey Adam. 

The asyncio example is a good one. Sometimes you're trying hard to build a 
test in the first place — it might just be that you didn't manage to await 
your coroutine. Oh well... — for me, I'd be making sure we cleaned that up 
before merge (or, can you filter those... — I guess you can 🤔) but I 
wouldn't want to block development on a "I can't get the tests to pass". 
Does that make sense? 

Maybe we should be stricter, but that's my first thought. 

Kind Regards,

Carlton


On Thursday, 29 October 2020 at 11:38:02 UTC+1 Adam Johnson wrote:

> Python has the concept of *unraisable exceptions* - exceptions that 
> cannot be raised at the time they occur because they would break something 
> about the runtime. For example, an exception raised during an object's 
> __del__ method would break garbage collection.
> Python 3.8 added the ability to take action when unraisable exceptions 
> occur, by setting sys.unraisablehook to a callable ( 
> https://docs.python.org/3.8/library/sys.html#sys.unraisablehook ). I 
> propose that we extend Django's test runner to add such a hook that records 
> if any unraisable exceptions occur during a test run, and fails the test 
> run if this is the case.
>
> The use case I came across for this was using asyncio in debug mode, 
> which warns about unawaited coroutines and unretrieved futures ( 
> https://docs.python.org/3.8/library/asyncio-dev.html#detect-never-awaited-coroutines
>  
> ). It can be very handy to add a warning filter to turn these 
> RuntimeWarnings into exceptions in tests and development. Unfortunately 
> such exceptions are always (or often?) *unraisable*, so Python prints 
> their stack trace with the default unraisable hook, but carries on as if no 
> error occurred. Failing test runs if unraisable exceptions occur could help 
> highlight such issues.
>
> I'm writing to the mailing list because I'm not sure if failing the test 
> run would *always* make sense. Does anyone else have experience with 
> unraisable exceptions?
>
> FWIW, pytest has only one stalled discussion: 
> https://github.com/pytest-dev/pytest/issues/5299
> -- 
> Adam
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/df093ae7-5559-42ef-8ca7-3af551a0d14an%40googlegroups.com.
  • Fai... Adam Johnson
    • ... Carlton Gibson
      • ... Adam Johnson
        • ... Carlton Gibson
          • ... Adam Johnson
            • ... Carlton Gibson
              • ... Adam Johnson
                • ... Tom Forbes
                • ... Carlton Gibson
                • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to