Show More
@@ -1,4 +1,5 | |||||
1 | """test View objects""" |
|
1 | """test View objects""" | |
|
2 | # -*- coding: utf-8 -*- | |||
2 | #------------------------------------------------------------------------------- |
|
3 | #------------------------------------------------------------------------------- | |
3 | # Copyright (C) 2011 The IPython Development Team |
|
4 | # Copyright (C) 2011 The IPython Development Team | |
4 | # |
|
5 | # | |
@@ -32,7 +33,7 def setup(): | |||||
32 |
|
33 | |||
33 | class TestView(ClusterTestCase): |
|
34 | class TestView(ClusterTestCase): | |
34 |
|
35 | |||
35 | def test_crash_task(self): |
|
36 | def test_z_crash_task(self): | |
36 | """test graceful handling of engine death (balanced)""" |
|
37 | """test graceful handling of engine death (balanced)""" | |
37 | # self.add_engines(1) |
|
38 | # self.add_engines(1) | |
38 | ar = self.client[-1].apply_async(crash) |
|
39 | ar = self.client[-1].apply_async(crash) | |
@@ -44,7 +45,7 class TestView(ClusterTestCase): | |||||
44 | self.client.spin() |
|
45 | self.client.spin() | |
45 | self.assertFalse(eid in self.client.ids, "Engine should have died") |
|
46 | self.assertFalse(eid in self.client.ids, "Engine should have died") | |
46 |
|
47 | |||
47 | def test_crash_mux(self): |
|
48 | def test_z_crash_mux(self): | |
48 | """test graceful handling of engine death (direct)""" |
|
49 | """test graceful handling of engine death (direct)""" | |
49 | # self.add_engines(1) |
|
50 | # self.add_engines(1) | |
50 | eid = self.client.ids[-1] |
|
51 | eid = self.client.ids[-1] | |
@@ -413,6 +414,39 class TestView(ClusterTestCase): | |||||
413 | self.assertEquals(ar.get(), 111) |
|
414 | self.assertEquals(ar.get(), 111) | |
414 | ar = ip.magic_result('-2') |
|
415 | ar = ip.magic_result('-2') | |
415 | self.assertEquals(ar.msg_ids, [v.history[-2]]) |
|
416 | self.assertEquals(ar.msg_ids, [v.history[-2]]) | |
|
417 | ||||
|
418 | def test_unicode_execute(self): | |||
|
419 | """test executing unicode strings""" | |||
|
420 | v = self.client[-1] | |||
|
421 | v.block=True | |||
|
422 | code=u"a=u'é'" | |||
|
423 | v.execute(code) | |||
|
424 | self.assertEquals(v['a'], u'é') | |||
|
425 | ||||
|
426 | def test_unicode_apply_result(self): | |||
|
427 | """test unicode apply results""" | |||
|
428 | v = self.client[-1] | |||
|
429 | r = v.apply_sync(lambda : u'é') | |||
|
430 | self.assertEquals(r, u'é') | |||
|
431 | ||||
|
432 | def test_unicode_apply_arg(self): | |||
|
433 | """test passing unicode arguments to apply""" | |||
|
434 | v = self.client[-1] | |||
|
435 | ||||
|
436 | @interactive | |||
|
437 | def check_unicode(a, check): | |||
|
438 | assert isinstance(a, unicode), "%r is not unicode"%a | |||
|
439 | assert isinstance(check, bytes), "%r is not bytes"%check | |||
|
440 | assert a.encode('utf8') == check, "%s != %s"%(a,check) | |||
|
441 | ||||
|
442 | for s in [ u'é', u'ßø®∫','asdf'.decode() ]: | |||
|
443 | try: | |||
|
444 | v.apply_sync(check_unicode, s, s.encode('utf8')) | |||
|
445 | except error.RemoteError as e: | |||
|
446 | if e.ename == 'AssertionError': | |||
|
447 | self.fail(e.evalue) | |||
|
448 | else: | |||
|
449 | raise e | |||
416 |
|
450 | |||
417 |
|
451 | |||
418 |
|
452 |
General Comments 0
You need to be logged in to leave comments.
Login now