Simpilify PillowTestCase.delete_tempfile for pytest (#4139)

Simpilify PillowTestCase.delete_tempfile for pytest
This commit is contained in:
Hugo van Kemenade 2019-10-22 14:14:20 +03:00 committed by GitHub
commit 1a9be9ccbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,29 +53,11 @@ def convert_to_comparable(a, b):
class PillowTestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
# holds last result object passed to run method:
self.currentResult = None
def run(self, result=None):
self.currentResult = result # remember result for use later
unittest.TestCase.run(self, result) # call superclass run method
def delete_tempfile(self, path):
try:
ok = self.currentResult.wasSuccessful()
except AttributeError: # for pytest
ok = True
if ok:
# only clean out tempfiles if test passed
try:
os.remove(path)
except OSError:
pass # report?
else:
print("=== orphaned temp file: %s" % path)
def assert_deep_equal(self, a, b, msg=None):
try: