def test__unquote_failure_cases(self): cases = [ "'hello", "", "'", "'hello\\'", "'hel'lo'", "'''", ] for quoted in cases: with self.assertRaises(MultiValueGuc.ParseError): MultiValueGuc._unquote(quoted)
def test__unquote(self): cases = [ ('hello', 'hello'), ("''", ''), ("'hello'", 'hello'), ("'a\\b\\f\\n\\r\\tb'", 'a\b\f\n\r\tb'), ("'\\0\\1\\2\\3\\4\\5\\6\\7\\8\\9'", '\0\1\2\3\4\5\6\789'), ("'\\1\\01\\001\\0001'", '\x01\x01\x01\x001'), ("'\\1a1'", '\x01a1'), ("'\\377\\400\\776\\7777'", '\xFF\x00\xFE\xFF7'), ("''''", "'"), ] for quoted, unquoted in cases: self.assertEqual(MultiValueGuc._unquote(quoted), unquoted)