Cleanly catch keyboard interrupts during tests

When running the inventory tests on a development machine, using ctrl-c
to send sigint should gracefully finish the current test and clean up
the workspace (tests/inventory).

While most of our tests are well-behaved, without the catchbreak=True
option, sometimes the code would be interrupted in between file creation
and cleanup. Additionally, tearDownModule was never called, leaving
behind inventory/openstack_user_config.yml

This change allows the current test to finish, it's teardown methods to
run, and finally the tearDownModule function to execute, leaving behind
a clean workspace. Only the tests that directly touch the filesystem
were changed.

While this is not impactful for gate tests, it improves quality of life
for developers.

Change-Id: I992e514e58958264d90faab7bc295d6d8e89f039
This commit is contained in:
Nolan Brubaker 2017-07-06 15:37:45 -04:00
parent 16f0609040
commit f0e6184185
3 changed files with 3 additions and 3 deletions

View File

@ -102,4 +102,4 @@ class TestMultipleRuns(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest.main(catchbreak=True)

View File

@ -1400,4 +1400,4 @@ class TestInventoryGroupConstraints(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest.main(catchbreak=True)

View File

@ -127,4 +127,4 @@ class TestRemoveIpfunction(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest.main(catchbreak=True)