mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-09 08:00:49 +03:00
Simpilify PillowTestCase.delete_tempfile for pytest (#4139)
Simpilify PillowTestCase.delete_tempfile for pytest
This commit is contained in:
commit
1a9be9ccbd
|
@ -53,29 +53,11 @@ def convert_to_comparable(a, b):
|
||||||
|
|
||||||
|
|
||||||
class PillowTestCase(unittest.TestCase):
|
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):
|
def delete_tempfile(self, path):
|
||||||
try:
|
try:
|
||||||
ok = self.currentResult.wasSuccessful()
|
os.remove(path)
|
||||||
except AttributeError: # for pytest
|
except OSError:
|
||||||
ok = True
|
pass # report?
|
||||||
|
|
||||||
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):
|
def assert_deep_equal(self, a, b, msg=None):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user