Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Side by Side Diff: Lib/test/test_inspect.py

Issue 1764286: inspect.getsource does not work with decorated functions
Patch Set: Created 6 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/inspect_fodder2.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import re 1 import re
2 import sys 2 import sys
3 import types 3 import types
4 import unittest 4 import unittest
5 import inspect 5 import inspect
6 import linecache 6 import linecache
7 import datetime 7 import datetime
8 import collections 8 import collections
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 linecache.getlines = getlines 341 linecache.getlines = getlines
342 342
343 class TestDecorators(GetSourceBase): 343 class TestDecorators(GetSourceBase):
344 fodderModule = mod2 344 fodderModule = mod2
345 345
346 def test_wrapped_decorator(self): 346 def test_wrapped_decorator(self):
347 self.assertSourceEqual(mod2.wrapped, 14, 17) 347 self.assertSourceEqual(mod2.wrapped, 14, 17)
348 348
349 def test_replacing_decorator(self): 349 def test_replacing_decorator(self):
350 self.assertSourceEqual(mod2.gone, 9, 10) 350 self.assertSourceEqual(mod2.gone, 9, 10)
351
352 def test_getsource_unwrap(self):
353 self.assertSourceEqual(mod2.real, 122, 124)
351 354
352 class TestOneliners(GetSourceBase): 355 class TestOneliners(GetSourceBase):
353 fodderModule = mod2 356 fodderModule = mod2
354 def test_oneline_lambda(self): 357 def test_oneline_lambda(self):
355 # Test inspect.getsource with a one-line lambda function. 358 # Test inspect.getsource with a one-line lambda function.
356 self.assertSourceEqual(mod2.oll, 25, 25) 359 self.assertSourceEqual(mod2.oll, 25, 25)
357 360
358 def test_threeline_lambda(self): 361 def test_threeline_lambda(self):
359 # Test inspect.getsource with a three-line lambda function, 362 # Test inspect.getsource with a three-line lambda function,
360 # where the second and third lines are _not_ indented. 363 # where the second and third lines are _not_ indented.
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases, 2447 TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases,
2445 TestInterpreterStack, TestClassesAndFunctions, TestPredicates, 2448 TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
2446 TestGetcallargsFunctions, TestGetcallargsMethods, 2449 TestGetcallargsFunctions, TestGetcallargsMethods,
2447 TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState, 2450 TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState,
2448 TestNoEOL, TestSignatureObject, TestSignatureBind, TestParameterObject, 2451 TestNoEOL, TestSignatureObject, TestSignatureBind, TestParameterObject,
2449 TestBoundArguments, TestGetClosureVars, TestUnwrap, TestMain 2452 TestBoundArguments, TestGetClosureVars, TestUnwrap, TestMain
2450 ) 2453 )
2451 2454
2452 if __name__ == "__main__": 2455 if __name__ == "__main__":
2453 test_main() 2456 test_main()
OLDNEW
« no previous file with comments | « Lib/test/inspect_fodder2.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+