improve error handling in tests/basic.py
diff --git a/tests/basic.py b/tests/basic.py
index e7b525e..5220b26 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -67,7 +67,7 @@
         print "Received interrupt signal; exiting"
         self.clean_shutdown = False
         self.tearDown()
-        sys.exit(1)
+        raise KeyboardInterrupt
 
     def setUp(self):
         self.logger = basic_logger
@@ -84,11 +84,9 @@
         # compatibilty?
         self.controller.connect(timeout=20)
         if not self.controller.active:
-            print "Controller startup failed; exiting"
-            sys.exit(1)
+            raise Exception("Controller startup failed")
         if self.controller.switch_addr is None: 
-            print "Controller startup failed (no switch addr); exiting"
-            sys.exit(1)
+            raise Exception("Controller startup failed (no switch addr)")
         basic_logger.info("Connected " + str(self.controller.switch_addr))
 
     def inheritSetup(self, parent):
@@ -154,7 +152,8 @@
     def tearDown(self):
         basic_logger.info("Teardown for simple dataplane test")
         SimpleProtocol.tearDown(self)
-        self.dataplane.kill(join_threads=self.clean_shutdown)
+        if hasattr(self, 'dataplane'):
+            self.dataplane.kill(join_threads=self.clean_shutdown)
         basic_logger.info("Teardown done")
 
     def runTest(self):
@@ -173,7 +172,7 @@
         print "Received interrupt signal; exiting"
         self.clean_shutdown = False
         self.tearDown()
-        sys.exit(1)
+        raise KeyboardInterrupt
 
     def setUp(self):
         self.clean_shutdown = False