def testSetGlobalStyle(self): try: style.SetGlobalStyle(style.CreateYapfStyle()) unformatted_code = textwrap.dedent(u"""\ for i in range(5): print('bar') """) expected_formatted_code = textwrap.dedent(u"""\ for i in range(5): print('bar') """) llines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines)) finally: style.SetGlobalStyle(style.CreatePEP8Style()) style.DEFAULT_STYLE = self.current_style unformatted_code = textwrap.dedent(u"""\ for i in range(5): print('bar') """) expected_formatted_code = textwrap.dedent(u"""\ for i in range(5): print('bar') """) llines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
def setUpClass(cls): style.SetGlobalStyle(style.CreateYapfStyle())