def _pyformat(code: str, **params): import pyformat return pyformat.format_code( code, aggressive=True, apply_config=False, remove_all_unused_imports=False, remove_unused_variables=False, )
def test_format_code_with_remove_unused_variables(self): self.assertEqual( 'def test():\n return 42\n', pyformat.format_code('def test():\n x = 4\n return 42', aggressive=True, remove_unused_variables=True))
def test_format_code_with_unicode(self): self.assertEqual("x = 'abc' \\\n 'ö'\n", pyformat.format_code('x = "abc" \\\n"ö"\n'))
def test_format_code_with_remove_all_unused_imports(self): self.assertEqual( "x = 'abc' \\\n 'ö'\n", pyformat.format_code('import my_module\nx = "abc" \\\n"ö"\n', aggressive=True, remove_all_unused_imports=True))
def test_format_code_without_aggressive(self): self.assertEqual( 'import os\nTrue\n', pyformat.format_code('import os\nTrue\n', aggressive=False))
def test_format_code(self): self.assertEqual("x = 'abc' \\\n 'next'\n", pyformat.format_code('x = "abc" \\\n"next"\n'))
def test_format_code_with_unicode(self): self.assertEqual("x = 'abc' \\\n 'ö'\n", pyformat.format_code( 'x = "abc" \\\n"ö"\n'))
def test_format_code_without_aggressive(self): self.assertEqual('import os\nTrue\n', pyformat.format_code( 'import os\nTrue\n', aggressive=False))
def test_format_code(self): self.assertEqual("x = 'abc' \\\n 'next'\n", pyformat.format_code( 'x = "abc" \\\n"next"\n'))