Fix test check for raised exception
diff --git a/yapftests/yapf_test.py b/yapftests/yapf_test.py
index 4fdb892..7ee8a0c 100644
--- a/yapftests/yapf_test.py
+++ b/yapftests/yapf_test.py
@@ -282,14 +282,11 @@
           print_diff=True)
 
   def testNoFile(self):
-    stream = StringIO()
-    handler = logging.StreamHandler(stream)
-    logger = logging.getLogger('mylogger')
-    logger.addHandler(handler)
-    self.assertRaises(
-        IOError, yapf_api.FormatFile, 'not_a_file.py', logger=logger.error)
-    self.assertEqual(stream.getvalue(),
-                     "[Errno 2] No such file or directory: 'not_a_file.py'\n")
+    with self.assertRaises(IOError) as context:
+      yapf_api.FormatFile('not_a_file.py')
+
+    self.assertEqual(str(context.exception),
+		     "[Errno 2] No such file or directory: 'not_a_file.py'")
 
   def testCommentsUnformatted(self):
     code = textwrap.dedent("""\