def METHOD_NAME(self):
    """
    Ensure that illegal attributes in a queryformat string along with legal
    attributes are properly escaped.
    """
    pkg = dnf.cli.commands.repoquery.PackageWrapper(PkgStub())
    fmt = dnf.cli.commands.repoquery.rpm2py_format(
        "%{name} | %{base} | {brackets}").format(pkg)
    self.assertEqual(fmt, "foobar | %{base} | {brackets}")