@@ -423,32 +423,34 @@ def testGetDescriptionWithoutDocstring(self):
423
423
self .assertEqual (
424
424
result .getDescription (self ),
425
425
'testGetDescriptionWithoutDocstring (' + __name__ +
426
- '.Test_TextTestResult)' )
426
+ '.Test_TextTestResult.testGetDescriptionWithoutDocstring )' )
427
427
428
428
def testGetSubTestDescriptionWithoutDocstring (self ):
429
429
with self .subTest (foo = 1 , bar = 2 ):
430
430
result = unittest .TextTestResult (None , True , 1 )
431
431
self .assertEqual (
432
432
result .getDescription (self ._subtest ),
433
433
'testGetSubTestDescriptionWithoutDocstring (' + __name__ +
434
- '.Test_TextTestResult) (foo=1, bar=2)' )
434
+ '.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstring) (foo=1, bar=2)' )
435
+
435
436
with self .subTest ('some message' ):
436
437
result = unittest .TextTestResult (None , True , 1 )
437
438
self .assertEqual (
438
439
result .getDescription (self ._subtest ),
439
440
'testGetSubTestDescriptionWithoutDocstring (' + __name__ +
440
- '.Test_TextTestResult) [some message]' )
441
+ '.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstring ) [some message]' )
441
442
442
443
def testGetSubTestDescriptionWithoutDocstringAndParams (self ):
443
444
with self .subTest ():
444
445
result = unittest .TextTestResult (None , True , 1 )
445
446
self .assertEqual (
446
447
result .getDescription (self ._subtest ),
447
448
'testGetSubTestDescriptionWithoutDocstringAndParams '
448
- '(' + __name__ + '.Test_TextTestResult) (<subtest>)' )
449
+ '(' + __name__ + '.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstringAndParams) '
450
+ '(<subtest>)' )
449
451
450
452
def testGetSubTestDescriptionForFalsyValues (self ):
451
- expected = 'testGetSubTestDescriptionForFalsyValues (%s.Test_TextTestResult) [%s]'
453
+ expected = 'testGetSubTestDescriptionForFalsyValues (%s.Test_TextTestResult.testGetSubTestDescriptionForFalsyValues ) [%s]'
452
454
result = unittest .TextTestResult (None , True , 1 )
453
455
for arg in [0 , None , []]:
454
456
with self .subTest (arg ):
@@ -464,7 +466,8 @@ def testGetNestedSubTestDescriptionWithoutDocstring(self):
464
466
self .assertEqual (
465
467
result .getDescription (self ._subtest ),
466
468
'testGetNestedSubTestDescriptionWithoutDocstring '
467
- '(' + __name__ + '.Test_TextTestResult) (baz=2, bar=3, foo=1)' )
469
+ '(' + __name__ + '.Test_TextTestResult.testGetNestedSubTestDescriptionWithoutDocstring) '
470
+ '(baz=2, bar=3, foo=1)' )
468
471
469
472
def testGetDuplicatedNestedSubTestDescriptionWithoutDocstring (self ):
470
473
with self .subTest (foo = 1 , bar = 2 ):
@@ -473,7 +476,7 @@ def testGetDuplicatedNestedSubTestDescriptionWithoutDocstring(self):
473
476
self .assertEqual (
474
477
result .getDescription (self ._subtest ),
475
478
'testGetDuplicatedNestedSubTestDescriptionWithoutDocstring '
476
- '(' + __name__ + '.Test_TextTestResult) (baz=3, bar=4, foo=1)' )
479
+ '(' + __name__ + '.Test_TextTestResult.testGetDuplicatedNestedSubTestDescriptionWithoutDocstring ) (baz=3, bar=4, foo=1)' )
477
480
478
481
@unittest .skipIf (sys .flags .optimize >= 2 ,
479
482
"Docstrings are omitted with -O2 and above" )
@@ -483,7 +486,7 @@ def testGetDescriptionWithOneLineDocstring(self):
483
486
self .assertEqual (
484
487
result .getDescription (self ),
485
488
('testGetDescriptionWithOneLineDocstring '
486
- '(' + __name__ + '.Test_TextTestResult)\n '
489
+ '(' + __name__ + '.Test_TextTestResult.testGetDescriptionWithOneLineDocstring )\n '
487
490
'Tests getDescription() for a method with a docstring.' ))
488
491
489
492
@unittest .skipIf (sys .flags .optimize >= 2 ,
@@ -495,7 +498,9 @@ def testGetSubTestDescriptionWithOneLineDocstring(self):
495
498
self .assertEqual (
496
499
result .getDescription (self ._subtest ),
497
500
('testGetSubTestDescriptionWithOneLineDocstring '
498
- '(' + __name__ + '.Test_TextTestResult) (foo=1, bar=2)\n '
501
+ '(' + __name__ + '.Test_TextTestResult.testGetSubTestDescriptionWithOneLineDocstring) '
502
+ '(foo=1, bar=2)\n '
503
+
499
504
'Tests getDescription() for a method with a docstring.' ))
500
505
501
506
@unittest .skipIf (sys .flags .optimize >= 2 ,
@@ -508,7 +513,7 @@ def testGetDescriptionWithMultiLineDocstring(self):
508
513
self .assertEqual (
509
514
result .getDescription (self ),
510
515
('testGetDescriptionWithMultiLineDocstring '
511
- '(' + __name__ + '.Test_TextTestResult)\n '
516
+ '(' + __name__ + '.Test_TextTestResult.testGetDescriptionWithMultiLineDocstring )\n '
512
517
'Tests getDescription() for a method with a longer '
513
518
'docstring.' ))
514
519
@@ -523,7 +528,8 @@ def testGetSubTestDescriptionWithMultiLineDocstring(self):
523
528
self .assertEqual (
524
529
result .getDescription (self ._subtest ),
525
530
('testGetSubTestDescriptionWithMultiLineDocstring '
526
- '(' + __name__ + '.Test_TextTestResult) (foo=1, bar=2)\n '
531
+ '(' + __name__ + '.Test_TextTestResult.testGetSubTestDescriptionWithMultiLineDocstring) '
532
+ '(foo=1, bar=2)\n '
527
533
'Tests getDescription() for a method with a longer '
528
534
'docstring.' ))
529
535
@@ -582,36 +588,36 @@ def testDotsOutput(self):
582
588
def testLongOutput (self ):
583
589
classname = f'{ __name__ } .{ self .Test .__qualname__ } '
584
590
self .assertEqual (self ._run_test ('testSuccess' , 2 ),
585
- f'testSuccess ({ classname } ) ... ok\n ' )
591
+ f'testSuccess ({ classname } .testSuccess ) ... ok\n ' )
586
592
self .assertEqual (self ._run_test ('testSkip' , 2 ),
587
- f"testSkip ({ classname } ) ... skipped 'skip'\n " )
593
+ f"testSkip ({ classname } .testSkip ) ... skipped 'skip'\n " )
588
594
self .assertEqual (self ._run_test ('testFail' , 2 ),
589
- f'testFail ({ classname } ) ... FAIL\n ' )
595
+ f'testFail ({ classname } .testFail ) ... FAIL\n ' )
590
596
self .assertEqual (self ._run_test ('testError' , 2 ),
591
- f'testError ({ classname } ) ... ERROR\n ' )
597
+ f'testError ({ classname } .testError ) ... ERROR\n ' )
592
598
self .assertEqual (self ._run_test ('testExpectedFailure' , 2 ),
593
- f'testExpectedFailure ({ classname } ) ... expected failure\n ' )
599
+ f'testExpectedFailure ({ classname } .testExpectedFailure ) ... expected failure\n ' )
594
600
self .assertEqual (self ._run_test ('testUnexpectedSuccess' , 2 ),
595
- f'testUnexpectedSuccess ({ classname } ) ... unexpected success\n ' )
601
+ f'testUnexpectedSuccess ({ classname } .testUnexpectedSuccess ) ... unexpected success\n ' )
596
602
597
603
def testDotsOutputSubTestSuccess (self ):
598
604
self .assertEqual (self ._run_test ('testSubTestSuccess' , 1 ), '.' )
599
605
600
606
def testLongOutputSubTestSuccess (self ):
601
607
classname = f'{ __name__ } .{ self .Test .__qualname__ } '
602
608
self .assertEqual (self ._run_test ('testSubTestSuccess' , 2 ),
603
- f'testSubTestSuccess ({ classname } ) ... ok\n ' )
609
+ f'testSubTestSuccess ({ classname } .testSubTestSuccess ) ... ok\n ' )
604
610
605
611
def testDotsOutputSubTestMixed (self ):
606
612
self .assertEqual (self ._run_test ('testSubTestMixed' , 1 ), 'sFE' )
607
613
608
614
def testLongOutputSubTestMixed (self ):
609
615
classname = f'{ __name__ } .{ self .Test .__qualname__ } '
610
616
self .assertEqual (self ._run_test ('testSubTestMixed' , 2 ),
611
- f'testSubTestMixed ({ classname } ) ... \n '
612
- f" testSubTestMixed ({ classname } ) [skip] (b=2) ... skipped 'skip'\n "
613
- f' testSubTestMixed ({ classname } ) [fail] (c=3) ... FAIL\n '
614
- f' testSubTestMixed ({ classname } ) [error] (d=4) ... ERROR\n ' )
617
+ f'testSubTestMixed ({ classname } .testSubTestMixed ) ... \n '
618
+ f" testSubTestMixed ({ classname } .testSubTestMixed ) [skip] (b=2) ... skipped 'skip'\n "
619
+ f' testSubTestMixed ({ classname } .testSubTestMixed ) [fail] (c=3) ... FAIL\n '
620
+ f' testSubTestMixed ({ classname } .testSubTestMixed ) [error] (d=4) ... ERROR\n ' )
615
621
616
622
def testDotsOutputTearDownFail (self ):
617
623
out = self ._run_test ('testSuccess' , 1 , AssertionError ('fail' ))
@@ -627,19 +633,19 @@ def testLongOutputTearDownFail(self):
627
633
classname = f'{ __name__ } .{ self .Test .__qualname__ } '
628
634
out = self ._run_test ('testSuccess' , 2 , AssertionError ('fail' ))
629
635
self .assertEqual (out ,
630
- f'testSuccess ({ classname } ) ... FAIL\n ' )
636
+ f'testSuccess ({ classname } .testSuccess ) ... FAIL\n ' )
631
637
out = self ._run_test ('testError' , 2 , AssertionError ('fail' ))
632
638
self .assertEqual (out ,
633
- f'testError ({ classname } ) ... ERROR\n '
634
- f'testError ({ classname } ) ... FAIL\n ' )
639
+ f'testError ({ classname } .testError ) ... ERROR\n '
640
+ f'testError ({ classname } .testError ) ... FAIL\n ' )
635
641
out = self ._run_test ('testFail' , 2 , Exception ('error' ))
636
642
self .assertEqual (out ,
637
- f'testFail ({ classname } ) ... FAIL\n '
638
- f'testFail ({ classname } ) ... ERROR\n ' )
643
+ f'testFail ({ classname } .testFail ) ... FAIL\n '
644
+ f'testFail ({ classname } .testFail ) ... ERROR\n ' )
639
645
out = self ._run_test ('testSkip' , 2 , AssertionError ('fail' ))
640
646
self .assertEqual (out ,
641
- f"testSkip ({ classname } ) ... skipped 'skip'\n "
642
- f'testSkip ({ classname } ) ... FAIL\n ' )
647
+ f"testSkip ({ classname } .testSkip ) ... skipped 'skip'\n "
648
+ f'testSkip ({ classname } .testSkip ) ... FAIL\n ' )
643
649
644
650
645
651
classDict = dict (unittest .TestResult .__dict__ )
@@ -852,7 +858,7 @@ def test_foo(self):
852
858
expected_out = '\n Stdout:\n set up\n '
853
859
self .assertEqual (stdout .getvalue (), expected_out )
854
860
self .assertEqual (len (result .errors ), 1 )
855
- description = f'test_foo ({ strclass (Foo )} )'
861
+ description = f'test_foo ({ strclass (Foo )} .test_foo )'
856
862
test_case , formatted_exc = result .errors [0 ]
857
863
self .assertEqual (str (test_case ), description )
858
864
self .assertIn ('ZeroDivisionError: division by zero' , formatted_exc )
@@ -874,7 +880,7 @@ def test_foo(self):
874
880
expected_out = '\n Stdout:\n tear down\n '
875
881
self .assertEqual (stdout .getvalue (), expected_out )
876
882
self .assertEqual (len (result .errors ), 1 )
877
- description = f'test_foo ({ strclass (Foo )} )'
883
+ description = f'test_foo ({ strclass (Foo )} .test_foo )'
878
884
test_case , formatted_exc = result .errors [0 ]
879
885
self .assertEqual (str (test_case ), description )
880
886
self .assertIn ('ZeroDivisionError: division by zero' , formatted_exc )
@@ -897,7 +903,7 @@ def test_foo(self):
897
903
expected_out = '\n Stdout:\n set up\n do cleanup2\n do cleanup1\n '
898
904
self .assertEqual (stdout .getvalue (), expected_out )
899
905
self .assertEqual (len (result .errors ), 2 )
900
- description = f'test_foo ({ strclass (Foo )} )'
906
+ description = f'test_foo ({ strclass (Foo )} .test_foo )'
901
907
test_case , formatted_exc = result .errors [0 ]
902
908
self .assertEqual (str (test_case ), description )
903
909
self .assertIn ('ValueError: bad cleanup2' , formatted_exc )
@@ -928,7 +934,7 @@ def test_foo(self):
928
934
expected_out = '\n Stdout:\n set up\n do cleanup2\n do cleanup1\n '
929
935
self .assertEqual (stdout .getvalue (), expected_out )
930
936
self .assertEqual (len (result .errors ), 3 )
931
- description = f'test_foo ({ strclass (Foo )} )'
937
+ description = f'test_foo ({ strclass (Foo )} .test_foo )'
932
938
test_case , formatted_exc = result .errors [0 ]
933
939
self .assertEqual (str (test_case ), description )
934
940
self .assertIn ('ZeroDivisionError: division by zero' , formatted_exc )
@@ -971,7 +977,7 @@ def test_foo(self):
971
977
expected_out = '\n Stdout:\n set up\n tear down\n do cleanup2\n do cleanup1\n '
972
978
self .assertEqual (stdout .getvalue (), expected_out )
973
979
self .assertEqual (len (result .errors ), 3 )
974
- description = f'test_foo ({ strclass (Foo )} )'
980
+ description = f'test_foo ({ strclass (Foo )} .test_foo )'
975
981
test_case , formatted_exc = result .errors [0 ]
976
982
self .assertEqual (str (test_case ), description )
977
983
self .assertIn ('ZeroDivisionError: division by zero' , formatted_exc )
0 commit comments