i prefer this test code reusing  the difference of arguments  ex  and  except  is instance and type only  so how about changing here to def  test migrate server deals with expected exceptions self  ex  excep def  test migrate server deals with expected exceptions self  ex instance fake instance fake db instance uuid  uuid vm state vm states active inst obj instance obj instance  from db object class conductortasktestcase  basetasktestcase  test compute basetestcase self conductor utils exceptionhelper self conductor self assertraises excep self assertraises type ex self conductor migrate server  self context  inst obj host destination true  false  none block migration disk over commit class conductortasktestcase  basetasktestcase  test compute basetestcase  disk over commit  def test migrate server deals with destinationhypervisortold self ex exc destinationhypervisortold self  test migrate server deals with expected exceptions ex ex ex exc destinationhypervisortold self  test migrate server deals with expected exceptions ex def test migrate server deals with hypervisorunablailable self ex exc hypervisorunavailable self  test migrate server deals with expected exceptions ex host  dummy ex ex exc hypervisorunavailable host  dummy self  test migrate server deals with expected exceptions ex  