From 998156898259379f87f3f628c3287522a9b53214 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 12 Oct 2019 10:39:21 -0700 Subject: [PATCH] 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. --- Tests/helper.py | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/Tests/helper.py b/Tests/helper.py index 466d04bda..3de828c3b 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -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: