unittest.TestCase.assertWarns() fails with RuntimeError when py is imported.
This simple unit test:
import unittest
import warnings
import pandas as pd # imports py.* somewhere deep
class Case(unittest.TestCase):
def test_assertWarns(self):
with self.assertWarns(UserWarning):
warnings.warn('Some warning')
when run with:
python -m unittest example.py
fails with:
======================================================================
ERROR: test_assertWarns (example.Case)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/example.py", line 9, in test_assertWarns
with self.assertWarns(UserWarning):
File "/usr/lib/python3.4/unittest/case.py", line 205, in __enter__
for v in sys.modules.values():
RuntimeError: dictionary changed size during iteration
----------------------------------------------------------------------
While I agree this is a unittest module issue (CPython bug 29620), I should hope it can be more quickly resolved on the pylib's side.
unittest.TestCase.assertWarns()
fails withRuntimeError
whenpy
is imported.This simple unit test:
when run with:
fails with:
While I agree this is a unittest module issue (CPython bug 29620), I should hope it can be more quickly resolved on the pylib's side.
Ref: https://github.com/pytest-dev/pytest/issues/1288