@@ 450-469 (lines=20) @@ | ||
447 | ])) |
|
448 | ||
449 | ||
450 | def test_story_half_play_proxy_class(): |
|
451 | assert test_mod.Stuff(1, 2).mix(3, 4) == (1, 2, 3, 4) |
|
452 | ||
453 | with Story(test_mod) as story: |
|
454 | obj = test_mod.Stuff(1, 2) |
|
455 | obj.mix(3, 4) == (1, 2, 3, 4) |
|
456 | ||
457 | with story.replay(recurse_lock=True, proxy=True, strict=False) as replay: |
|
458 | obj = test_mod.Stuff(1, 2) |
|
459 | assert obj.mix(3, 4) == (1, 2, 3, 4) |
|
460 | assert obj.meth() is None |
|
461 | ||
462 | raises(TypeError, obj.meth, 123) |
|
463 | ||
464 | obj = test_mod.Stuff(0, 1) |
|
465 | assert obj.mix('a', 'b') == (0, 1, 'a', 'b') |
|
466 | assert obj.mix(3, 4) == (0, 1, 3, 4) |
|
467 | ||
468 | raises(TypeError, obj.meth, 123) |
|
469 | assert replay.unexpected == format_calls(OrderedDict([ |
|
470 | (('stuff_1', 'meth', '', ''), _Returns('None')), |
|
471 | (('stuff_1', 'meth', '123', ''), _Raises(repr_ex(TypeError( |
|
472 | 'meth() takes exactly 1 argument (2 given)' if PY2 else |
|
@@ 416-432 (lines=17) @@ | ||
413 | """ |
|
414 | ||
415 | ||
416 | def test_story_empty_play_proxy_class(): |
|
417 | assert test_mod.Stuff(1, 2).mix(3, 4) == (1, 2, 3, 4) |
|
418 | ||
419 | with Story(test_mod).replay(recurse_lock=True, proxy=True, strict=False) as replay: |
|
420 | obj = test_mod.Stuff(1, 2) |
|
421 | assert obj.mix(3, 4) == (1, 2, 3, 4) |
|
422 | assert obj.mix('a', 'b') == (1, 2, 'a', 'b') |
|
423 | ||
424 | raises(TypeError, obj.meth, 123) |
|
425 | ||
426 | obj = test_mod.Stuff(0, 1) |
|
427 | assert obj.mix('a', 'b') == (0, 1, 'a', 'b') |
|
428 | assert obj.mix(3, 4) == (0, 1, 3, 4) |
|
429 | ||
430 | raises(TypeError, obj.meth, 123) |
|
431 | ||
432 | assert format_calls(replay._actual) == format_calls(OrderedDict([ |
|
433 | ((None, 'test_pkg1.test_pkg2.test_mod.Stuff', "1, 2", ''), _Binds('stuff_1')), |
|
434 | (('stuff_1', 'mix', "3, 4", ''), _Returns("(1, 2, 3, 4)")), |
|
435 | (('stuff_1', 'mix', "'a', 'b'", ''), _Returns("(1, 2, 'a', 'b')")), |