def test_map_collection(self): vals = OrderedDict() vals['a'] = 'a' vals['b'] = 'b' vals['c'] = 'c' result = bind_params("%s", (vals, ), Encoder()) self.assertEqual(result, "{'a': 'a', 'b': 'b', 'c': 'c'}")
def test_float_precision(self): f = 3.4028234663852886e+38 self.assertEqual(float(bind_params("%s", (f, ), Encoder())), f)
def test_quote_escaping(self): result = bind_params("%s", ("""'ef''ef"ef""ef'""", ), Encoder()) self.assertEqual(result, """'''ef''''ef"ef""ef'''""")
def test_list_collection(self): result = bind_params("%s", (['a', 'b', 'c'], ), Encoder()) self.assertEqual(result, "['a', 'b', 'c']")
def test_set_collection(self): result = bind_params("%s", (set(['a', 'b']), ), Encoder()) self.assertIn(result, ("{'a', 'b'}", "{'b', 'a'}"))
def test_none_param(self): result = bind_params("%s", (None, ), Encoder()) self.assertEqual(result, "NULL")
def test_generator_param(self): result = bind_params("%s", ((i for i in xrange(3)), ), Encoder()) self.assertEqual(result, "[0, 1, 2]")
def test_sequence_param(self): result = bind_params("%s", (ValueSequence((1, "a", 2.0)), ), Encoder()) self.assertEqual(result, "(1, 'a', 2.0)")
def test_bind_map(self): result = bind_params("%(a)s %(b)s %(c)s", dict(a=1, b="a", c=2.0), Encoder()) self.assertEqual(result, "1 'a' 2.0")
def test_bind_sequence(self): result = bind_params("%s %s %s", (1, "a", 2.0), Encoder()) self.assertEqual(result, "1 'a' 2.0")