diff --git a/mininet/test/test_nets.py b/mininet/test/test_nets.py
index 1a199c82a917f11af03751e9f0e7378bbaf286f1..97c4148849959fc9c4bd2b98adae05bf54e89c89 100755
--- a/mininet/test/test_nets.py
+++ b/mininet/test/test_nets.py
@@ -4,6 +4,7 @@
    Test creation and all-pairs ping for each included mininet topo type."""
 
 import unittest
+import sys
 from functools import partial
 
 from mininet.net import Mininet
@@ -12,6 +13,7 @@
 from mininet.topo import SingleSwitchTopo, LinearTopo
 from mininet.log import setLogLevel
 from mininet.util import quietRun
+from mininet.clean import cleanup
 
 # Tell pylint not to complain about calls to other class
 # pylint: disable=E1101
@@ -21,6 +23,11 @@ class testSingleSwitchCommon( object ):
 
     switchClass = None # overridden in subclasses
 
+    def tearDown( self ):
+        "Clean up if necessary"
+        if sys.exc_info != ( None, None, None ):
+            cleanup()
+
     def testMinimal( self ):
         "Ping test on minimal topology"
         mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller,