def test_mod_func(self): code = """print('leoBridgeTest.py: argv: %s' % repr(sys.argv))""" # pp_code_ast(code) expected = """print(f'leoBridgeTest.py: argv: {repr(sys.argv)}') """ result = fstringify_code(code, debug=True) self.assertCodeEqual(result, expected)
def test_mod_var_name(self): code = 'b = "1+%s+2" % a' expected = "b = f'1+{a}+2'\n" result = fstringify_code(code) self.assertCodeEqual(result, expected)
def test_mod_tuple(self): code = 'b = "1+%s+2%s3" % (a, b)' expected = "b = f'1+{a}+2{b}3'\n" result = fstringify_code(code) self.assertCodeEqual(result, expected)
def test_mod_str_literal(self): code = 'b = "1+%s+2" % "a"' expected = "b = f\"1+{'a'}+2\"\n" result = fstringify_code(code) self.assertCodeEqual(result, expected)