def join_fields(self, fields): parts = [] for name, val in fields.items(): if not isinstance(val, str): val = str(val) parts.append(name + '=' + quote(val)) return ', '.join(parts)
def test_quote_unprintable_chars(self): assert quote('\x8Ffoo\xA3bar').lower() == r'"\x8Ffoo\xA3bar"'.lower()
def test_quote_control_characters(self): assert quote("\r\n\t") == r'"\r\n\t"'
def test_will_escape(self): assert quote(r'foo"bar') == r'"foo\"bar"' assert quote(r'foo\bar') == r'"foo\\bar"'
def test_will_quote_string(self): assert quote('foobar') == '"foobar"' assert quote('foo bar baz') == '"foo bar baz"' assert quote('foobar', quote='`') == '`foobar`'