Closed giampaolo closed 5 months ago
For the record, at the moment I'm using this as a workaround in my own unit tests:
import warnings
import unittesting
class SublimeTestCase(unittesting.DeferrableTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
warnings.simplefilter("error") # for this process
os.environ["PYTHONWARNINGS"] = "default" # also for subprocesses
@classmethod
def tearDownClass(cls):
warnings.resetwarnings()
del os.environ["PYTHONWARNINGS"]
super().tearDownClass()
OK, this was easier than anticipated. Here's a PR (my second in this repo =)) which adds a new "warnings" settings: https://github.com/SublimeText/UnitTesting/pull/272
Fixed by #272
Python unittest module automatically enables warnings before starting the test suite:
UnitTesting package should do the same. This is important especially for
ResourceWarning
s. E.g. with warnings enabled the code below:...will print a warning like this in the console:
Official Python doc states https://docs.python.org/3/library/warnings.html#overriding-the-default-filter: