mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-25 00:34:14 +03:00
Simpilify PillowTestCase.delete_tempfile for pytest
As the test suite always runs with pytest now, self.currentResult is always None. Using this, can remove unused code.
This commit is contained in:
parent
6595ce1609
commit
9981568982
|
@ -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