File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -762,6 +762,25 @@ def test_test_program_fail_wo_buffer(self):
762762 self .assertIn ('should be printed' , r [0 ].getvalue ())
763763 self .assertNotIn ('should be printed' , r [1 ].getvalue ())
764764
765+ def test_partialmethod (self ):
766+ try :
767+ from functools import partialmethod
768+ except ImportError :
769+ raise unittest .SkipTest ('functools.partialmethod is not available.' )
770+ def test_partialmethod (test ):
771+ pass
772+ class TestWithPartialmethod (unittest .TestCase ):
773+ pass
774+ setattr (
775+ TestWithPartialmethod ,
776+ 'test_partialmethod' ,
777+ partialmethod (test_partialmethod ),
778+ )
779+ suite = unittest .TestSuite ()
780+ suite .addTest (TestWithPartialmethod ('test_partialmethod' ))
781+ self ._test_xmlrunner (suite )
782+
783+
765784
766785class DuplicateWriterTestCase (unittest .TestCase ):
767786 def setUp (self ):
Original file line number Diff line number Diff line change @@ -261,6 +261,8 @@ def startTest(self, test):
261261 test_class = type (test )
262262 # Note: inspect can get confused with decorators, so use class.
263263 self .filename = inspect .getsourcefile (test_class )
264+ # Handle partial and partialmethod objects.
265+ test_method = getattr (test_method , 'func' , test_method )
264266 _ , self .lineno = inspect .getsourcelines (test_method )
265267 finally :
266268 pass
You can’t perform that action at this time.
0 commit comments