Skip to content

Commit

Permalink
Simpilify PillowTestCase.delete_tempfile for pytest (#4139)
Browse files Browse the repository at this point in the history
Simpilify PillowTestCase.delete_tempfile for pytest
  • Loading branch information
hugovk committed Oct 22, 2019
2 parents 46d1b5a + 9981568 commit 1a9be9c
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions Tests/helper.py
Expand Up @@ -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)
os.remove(path)
except OSError:
pass # report?

def assert_deep_equal(self, a, b, msg=None):
try:
Expand Down

0 comments on commit 1a9be9c

Please sign in to comment.