def test_utf8dict(self): uk = "foobar" d = {u"følelser ær langé": u"ærbadægzaååÆØÅ", from_utf8(uk): from_utf8("xuzzybaz")} for key, value in http.utf8dict(d.items()).items(): self.assertIsInstance(key, str) self.assertIsInstance(value, str)
def test_from_message(self): us = u"æØåveéðƒeæ" body = { "task": mytask.name, "id": uuid(), "args": [2], "kwargs": { us: "bar" } } m = Message(None, body=anyjson.serialize(body), backend="foo", content_type="application/json", content_encoding="utf-8") tw = TaskRequest.from_message(m, m.decode()) self.assertIsInstance(tw, Request) self.assertEqual(tw.task_name, body["task"]) self.assertEqual(tw.task_id, body["id"]) self.assertEqual(tw.args, body["args"]) us = from_utf8(us) if sys.version_info < (2, 6): self.assertEqual(tw.kwargs.keys()[0], us) self.assertIsInstance(tw.kwargs.keys()[0], str) self.assertTrue(tw.logger)
def waitexec(self, argv, path=sys.executable): args = " ".join([path] + list(argv)) argstr = shellsplit(from_utf8(args)) pipe = Popen(argstr, env=self.env) self.info(" %s" % " ".join(argstr)) retcode = pipe.wait() if retcode < 0: self.note("* Child was terminated by signal %s" % (-retcode, )) return -retcode elif retcode > 0: self.note("* Child terminated with failure code %s" % (retcode, )) return retcode
def test_from_message(self): us = u"æØåveéðƒeæ" body = {"task": mytask.name, "id": uuid(), "args": [2], "kwargs": {us: "bar"}} m = Message(None, body=anyjson.serialize(body), backend="foo", content_type="application/json", content_encoding="utf-8") tw = TaskRequest.from_message(m, m.decode()) self.assertIsInstance(tw, TaskRequest) self.assertEqual(tw.task_name, body["task"]) self.assertEqual(tw.task_id, body["id"]) self.assertEqual(tw.args, body["args"]) us = from_utf8(us) self.assertEqual(tw.kwargs.keys()[0], us) self.assertIsInstance(tw.kwargs.keys()[0], str) self.assertTrue(tw.logger)
def test_on_failure_utf8_exception(self): self._test_on_failure(Exception(from_utf8(u"Бобры атакуют")))
def test_on_failure_utf8_exception(self): self._test_on_failure(Exception( from_utf8(u"Бобры атакуют")))