Commit 3761a415 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Add magic __del__ methods for stuff

parent b2bad734
......@@ -298,6 +298,7 @@ class Sifter:
extra={'entity': self.account}
)
def __del__(self):
rmtree(self.log_path)
......
......@@ -235,7 +235,7 @@ class Mover:
)
return count
def cleanup(self):
def __del__(self):
try:
rmtree(self.email_directory)
except OSError:
......@@ -361,7 +361,6 @@ def main():
mover = Mover(vars(args), config)
mover.transfer_mail()
mover.cleanup()
if __name__ == '__main__':
......
......@@ -20,7 +20,6 @@ def test_transfer_label_list():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
mover.cleanup()
def test_transfer_label_file():
......@@ -36,7 +35,6 @@ def test_transfer_label_file():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
mover.cleanup()
def test_prefix_assignment():
......@@ -52,7 +50,6 @@ def test_prefix_assignment():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
assert mover.transfer['label1']['destination'] == 'prefix-label1'
mover.cleanup()
def test_search_translation():
......@@ -70,7 +67,6 @@ def test_search_translation():
print(mover.transfer)
expected = 'weir---l-bel-'
assert mover.transfer['weir|) l^bel(']['dest_searchable'] == expected
mover.cleanup()
def test_with_existing_custom_dir():
......@@ -86,7 +82,6 @@ def test_with_existing_custom_dir():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
mover.cleanup()
def test_with_new_custom_dir():
......@@ -102,11 +97,7 @@ def test_with_new_custom_dir():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
if not os.path.isdir('/var/tmp/gtm1a2b3c4d'):
assert False
mover.cleanup()
if os.path.isdir('/var/tmp/gtm1a2b3c4d'):
assert False
assert os.path.isdir('/var/tmp/gtm1a2b3c4d')
def test_transfer_with_bad_current_owner():
......@@ -122,7 +113,6 @@ def test_transfer_with_bad_current_owner():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
mover.cleanup()
def test_transfer_with_bad_new_owner():
......@@ -138,4 +128,3 @@ def test_transfer_with_bad_new_owner():
yaml.load(open(config), Loader=yaml.BaseLoader)
)
mover.transfer_mail()
mover.cleanup()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment