1616from  aspectlib .utils  import  PY26 
1717from  aspectlib .utils  import  repr_ex 
1818
19- format_calls  =  lambda  calls : '' .join (_format_calls (calls ))
19+ pytest_plugins  =  'pytester' ,
20+ 21+ 22+ def  format_calls (calls ):
23+  return  '' .join (_format_calls (calls ))
2024
2125
2226def  module_fun (a , b = 2 ):
@@ -278,6 +282,7 @@ def test_xxx():
278282
279283 # TODO 
280284
285+ 281286def  test_story_text_helpers ():
282287 with  Story (test_mod ) as  story :
283288 obj  =  test_mod .Stuff (1 , 2 )
@@ -297,19 +302,19 @@ def test_story_text_helpers():
297302 test_mod .func (5 )
298303 test_mod .target (1 )
299304
300-  print (replay .missing )
305+  print (replay .missing )
301306 assert  replay .missing  ==  """stuff_1.meth('b') == 'y' # returns 
302307stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(2, 3) 
303308stuff_2.meth('c') == 'z' # returns 
304309test_pkg1.test_pkg2.test_mod.target(2) == 3 # returns 
305310""" 
306-  print (replay .unexpected )
311+  print (replay .unexpected )
307312 assert  replay .unexpected  ==  """stuff_1.meth() == None # returns 
308313stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(4, 4) 
309314stuff_2.meth() == None # returns 
310315test_pkg1.test_pkg2.test_mod.func(5) == None # returns 
311316""" 
312-  print (replay .diff )
317+  print (replay .diff )
313318 if  PY26 :
314319 assert  replay .diff  ==  """--- expected """  """ 
315320+++ actual """  """ 
@@ -344,7 +349,7 @@ def test_story_text_helpers():
344349""" 
345350
346351
347- def  test_story_empty_play_proxy_class_missing_report ():
352+ def  test_story_empty_play_proxy_class_missing_report (LineMatcher ):
348353 with  Story (test_mod ).replay (recurse_lock = True , proxy = True , strict = False ) as  replay :
349354 obj  =  test_mod .Stuff (1 , 2 )
350355 obj .mix (3 , 4 )
@@ -362,55 +367,29 @@ def test_story_empty_play_proxy_class_missing_report():
362367 obj .mix ()
363368 obj .meth ()
364369 obj .mix (10 )
365- 366-  print (repr (replay .diff ))
367- 368-  if  PY26 :
369-  assert  replay .diff  ==  """--- expected """  """ 
370- +++ actual """  """ 
371- @@ -1,0 +1,18 @@ 
372- +stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2) 
373- +stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns 
374- +stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns 
375- +stuff_1.raises(123) ** ValueError((123,),) # raises 
376- +stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1) 
377- +stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns 
378- +stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns 
379- +test_pkg1.test_pkg2.test_mod.target() == None # returns 
380- +test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',),) # raises 
381- +stuff_2.raises(123) ** ValueError((123,),) # raises 
382- +that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1) 
383- +that_long_stuf_1.mix(2) == (1, 2) # returns 
384- +that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3) 
385- +that_long_stuf_2.mix(4) == (3, 4) # returns 
386- +that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2) 
387- +that_long_stuf_3.mix() == (2,) # returns 
388- +that_long_stuf_3.meth() == None # returns 
389- +that_long_stuf_3.mix(10) == (2, 10) # returns 
390- """ 
391-  else :
392-  assert  replay .diff  ==  """--- expected 
393- +++ actual 
394- @@ -0,0 +1,18 @@ 
395- +stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2) 
396- +stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns 
397- +stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns 
398- +stuff_1.raises(123) ** ValueError((123,),) # raises 
399- +stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1) 
400- +stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns 
401- +stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns 
402- +test_pkg1.test_pkg2.test_mod.target() == None # returns 
403- +test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',),) # raises 
404- +stuff_2.raises(123) ** ValueError((123,),) # raises 
405- +that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1) 
406- +that_long_stuf_1.mix(2) == (1, 2) # returns 
407- +that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3) 
408- +that_long_stuf_2.mix(4) == (3, 4) # returns 
409- +that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2) 
410- +that_long_stuf_3.mix() == (2,) # returns 
411- +that_long_stuf_3.meth() == None # returns 
412- +that_long_stuf_3.mix(10) == (2, 10) # returns 
413- """ 
370+  LineMatcher (replay .diff .splitlines ()).fnmatch_lines ([
371+  "--- expected" ,
372+  "+++ actual" ,
373+  "@@ -0,0 +1,18 @@" ,
374+  "+stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2)" ,
375+  "+stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns" ,
376+  "+stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns" ,
377+  "+stuff_1.raises(123) ** ValueError((123,)*) # raises" ,
378+  "+stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1)" ,
379+  "+stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns" ,
380+  "+stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns" ,
381+  "+test_pkg1.test_pkg2.test_mod.target() == None # returns" ,
382+  "+test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',)*) # raises" ,
383+  "+stuff_2.raises(123) ** ValueError((123,)*) # raises" ,
384+  "+that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1)" ,
385+  "+that_long_stuf_1.mix(2) == (1, 2) # returns" ,
386+  "+that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3)" ,
387+  "+that_long_stuf_2.mix(4) == (3, 4) # returns" ,
388+  "+that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2)" ,
389+  "+that_long_stuf_3.mix() == (2,) # returns" ,
390+  "+that_long_stuf_3.meth() == None # returns" ,
391+  "+that_long_stuf_3.mix(10) == (2, 10) # returns" ,
392+  ])
414393
415394
416395def  test_story_empty_play_proxy_class ():
@@ -556,8 +535,8 @@ def test_story_create():
556535 assert  isinstance (obj , test_mod .Stuff )
557536 obj .meth ('other' , 1 , 2 ) ==  123 
558537 obj .mix ('other' ) ==  'mixymix' 
559-  #from pprint import pprint as print 
560-  #print (dict(story._calls)) 
538+  #from pprint import pprint as print 
539+  #print (dict(story._calls)) 
561540 assert  dict (story ._calls ) ==  {
562541 (None , 'test_pkg1.test_pkg2.test_mod.Stuff' , "'stuff'" , '' ): _Binds ('stuff_1' ),
563542 ('stuff_1' , 'meth' , "'other', 1, 2" , '' ): _Returns ("123" ),
@@ -567,6 +546,7 @@ def test_story_create():
567546 (None , 'test_pkg1.test_pkg2.test_mod.target' , "'a', 'b', 'c'" , '' ): _Returns ("'abc'" ),
568547 }
569548
549+ 570550def  xtest_story_empty_play_proxy_class_dependencies ():
571551 with  Story (test_mod ).replay (recurse_lock = True , proxy = True , strict = False ) as  replay :
572552 obj  =  test_mod .Stuff (1 , 2 )
0 commit comments