From f0e61841854961c8197c3a1bb4a09dad5e590a3e Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Thu, 6 Jul 2017 15:37:45 -0400 Subject: [PATCH] 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 --- tests/test_filesystem.py | 2 +- tests/test_inventory.py | 2 +- tests/test_manage.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 4ce0176657..6a656fa511 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -102,4 +102,4 @@ class TestMultipleRuns(unittest.TestCase): if __name__ == '__main__': - unittest.main() + unittest.main(catchbreak=True) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index 4f2b864212..2aa50bd25b 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -1400,4 +1400,4 @@ class TestInventoryGroupConstraints(unittest.TestCase): if __name__ == '__main__': - unittest.main() + unittest.main(catchbreak=True) diff --git a/tests/test_manage.py b/tests/test_manage.py index 0d05445aa9..aaeea1232f 100644 --- a/tests/test_manage.py +++ b/tests/test_manage.py @@ -127,4 +127,4 @@ class TestRemoveIpfunction(unittest.TestCase): if __name__ == '__main__': - unittest.main() + unittest.main(catchbreak=True)