summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' ↵Miss Islington (bot)2022-01-221-0/+11
| | | | | | | | | (GH-30285) (#30765) (cherry picked from commit 881a763cfe07ef4a5806ec78f13a9bc99e8909dc) Co-authored-by: Weipeng Hong <hongweichen8888@sina.com> Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
* bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638)Miss Islington (bot)2022-01-181-2/+2
| | | | | (cherry picked from commit a287b31bcb065e4122400cb59167340d25480e6d) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* bpo-45406: make inspect.getmodule() return None when getabsfile() raises ↵Miss Islington (bot)2021-11-021-0/+9
| | | | | | | FileNotFoundError (GH-28824) (cherry picked from commit a459a81530de700b3d3faeb827b22ed1c9985812) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* bpo-45438: format of inspect.Signature with generic builtins (GH-29212)Miss Islington (bot)2021-10-271-0/+11
| | | | | | | | | | Use types.GenericAlias in inspect.formatannotation to correctly add type arguments of builtin types to the string representation of Signatures. Co-authored-by: Martin Rückl <martin.rueckl@codecentric.de> (cherry picked from commit d02ffd1b5c0fd8dec6dd2f7e3f2b0cfae48b7899) Co-authored-by: Martin Rueckl <enigma@nbubu.de>
* [3.10] bpo-45229: Remove test_main in many tests (GH-28405) (GH-28455)Serhiy Storchaka2021-09-191-16/+2
| | | | | | | | | | | Instead of explicitly enumerate test classes for run_unittest() use the unittest ability to discover tests. This also makes these tests discoverable and runnable with unittest. load_tests() can be used for dynamic generating tests and adding doctests. setUpModule(), tearDownModule() and addModuleCleanup() can be used for running code before and after all module tests. (cherry picked from commit 40348acc180580371d25f75f46b27048e35f2435)
* bpo-44808: fixes test for interactive inspect getsource of a class (GH-27571)Miss Islington (bot)2021-08-031-12/+8
| | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 58325971de0faf330c9c38269dae8315a0746e59) Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
* bpo-44808: Fix test_inspect in refleak mode (GH-27544)Miss Islington (bot)2021-08-021-1/+2
| | | | | (cherry picked from commit 626d397cc1612ea5eef153dd910834c2ee00ddbd) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
* bpo-44648: Fix error type in inspect.getsource() in interactive session ↵Miss Islington (bot)2021-07-301-1/+16
| | | | | | | (GH-27171) (GH-27495) (cherry picked from commit 48a62559dfaf775e4f1cc56b19379c799e8e2587) Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
* bpo-40897:Give priority to using the current class constructor in ↵Miss Islington (bot)2021-07-161-0/+41
| | | | | | | | `inspect.signature` (GH-27177) (#27189) Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 6aab5f9bf303a8e4cd8377fabcdcb499e0541f9a) Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
* bpo-43817: Add inspect.get_annotations(). (#25522)larryhastings2021-04-301-5/+238
| | | | | Add inspect.get_annotations, which safely computes the annotations defined on an object. It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations can also correctly un-stringize stringized annotations. inspect.signature, inspect.from_callable, and inspect.from_function now call inspect.get_annotations to retrieve annotations. This means inspect.signature and inspect.from_callable can now un-stringize stringized annotations, too.
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-211-24/+28
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25189)Inada Naoki2021-04-061-6/+6
| | | | | | | | | | | | * Fix _sitebuiltins * Fix test_inspect * Fix test_interpreters * Fix test_io * Fix test_iter * Fix test_json * Fix test_linecache * Fix test_lltrace * Fix test_logging * Fix logging
* bpo-31861: Add aiter and anext to builtins (#23847)Joshua Bronson2021-03-231-0/+3
| | | | | | Co-authored-by: jab <jab@users.noreply.github.com> Co-authored-by: Daniel Pope <mauve@mauveweb.co.uk> Co-authored-by: Justin Wang <justin39@gmail.com>
* bpo-41960: Add globalns and localns parameters to inspect.signature and ↵Batuhan Taskaya2020-12-231-0/+20
| | | | Signature.from_callable (GH-22583)
* bpo-17735: inspect.findsource now raises OSError when co_lineno is out of ↵Irit Katriel2020-12-041-0/+11
| | | | | range (GH-23633) This can happen when a file was edited after it was imported.
* bpo-42116: Fix inspect.getsource handling of trailing comments (GH-23630)Irit Katriel2020-12-041-4/+19
|
* bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-24/+20
| | | | | The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
* bpo-40275: Use new test.support helper submodules in tests (GH-21727)Hai Shi2020-08-041-1/+3
|
* bpo-40257: Revert changes to inspect.getdoc() (GH-20073)Serhiy Storchaka2020-05-181-12/+3
|
* bpo-35113: Fix inspect.getsource to return correct source for inner classes ↵Karthikeyan Singaravelan2020-04-181-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#10307) * Use ast module to find class definition * Add NEWS entry * Fix class with multiple children and move decorator code to the method * Fix PR comments 1. Use node.decorator_list to select decorators 2. Remove unwanted variables in ClassVisitor 3. Simplify stack management as per review * Add test for nested functions and async calls * Fix pydoc test since comments are returned now correctly * Set event loop policy as None to fix environment related change * Refactor visit_AsyncFunctionDef and tests * Refactor to use local variables and fix tests * Add patch attribution * Use self.addCleanup for asyncio * Rename ClassVisitor to ClassFinder and fix asyncio cleanup * Return first class inside conditional in case of multiple definitions. Remove decorator for class source. * Add docstring to make the test correct * Modify NEWS entry regarding decorators * Return decorators too for bpo-15856 * Move ast and the class source code to top. Use proper Exception.
* bpo-40257: Output object's own docstring in pydoc (GH-19479)Serhiy Storchaka2020-04-151-3/+12
|
* bpo-39957: Change Signature.parameters to OrderedDict (GH-18988)Jens Reidel2020-03-181-1/+6
|
* bpo-36350: inspect: Replace OrderedDict with dict. (GH-12412)Rémi Lapeyre2020-01-281-0/+5
|
* bpo-38478: Correctly handle keyword argument with same name as ↵Pablo Galindo2019-10-151-0/+10
| | | | positional-only parameter (GH-16800)
* bpo-37206: Unrepresentable default values no longer represented as None. ↵Serhiy Storchaka2019-09-141-2/+2
| | | | | | | (GH-13933) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all.
* bpo-34706: Preserve subclassing in inspect.Signature.from_callable (GH-16108)Gregory P. Smith2019-09-131-2/+9
| | | | | | | | https://bugs.python.org/issue34706 Specifically in the case of a class that does not override its constructor signature inherited from object. These are Buck Evan @bukzor's changes cherrypicked from GH-9344.
* bpo-37685: Use singletons ALWAYS_EQ and NEVER_EQ in more tests. (GH-15167)Serhiy Storchaka2019-08-081-11/+7
|
* bpo-37173: Show passed class in inspect.getfile error (GH-13861)Philipp A2019-06-081-0/+18
| | | | | | | | | | | | | Currently, inspect.getfile(str) will report nonsense: ```pytb >>> inspect.getfile(str) TypeError: <module 'builtins' (built-in)> is a built-in class ``` This fixes that https://bugs.python.org/issue37173
* bpo-37099: Silence DeprecationWarning in test_inspect (GH-13679)Xtreak2019-05-301-6/+9
| | | | | | Fix DeprecationWarning introduced in aee19f54f6fe45f6b3c906987941e5a8af4468e9 https://bugs.python.org/issue37099
* bpo-36785: PEP 574 implementation (GH-7076)Antoine Pitrou2019-05-261-6/+5
|
* bpo-36751: Undeprecate getfullargspec (GH-13245)Pablo Galindo2019-05-161-34/+20
|
* bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)Serhiy Storchaka2019-05-061-0/+11
|
* bpo-36751: Deprecate getfullargspec and report positional-only args as ↵Pablo Galindo2019-04-301-34/+42
| | | | | | | | regular args (GH-13016) * bpo-36751: Deprecate getfullargspec and report positional-only args as regular args * Use inspect.signature in testhelpers
* bpo-36540: PEP 570 -- Implementation (GH-12701)Pablo Galindo2019-04-291-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains the implementation of PEP570: Python positional-only parameters. * Update Grammar/Grammar with new typedarglist and varargslist * Regenerate grammar files * Update and regenerate AST related files * Update code object * Update marshal.c * Update compiler and symtable * Regenerate importlib files * Update callable objects * Implement positional-only args logic in ceval.c * Regenerate frozen data * Update standard library to account for positional-only args * Add test file for positional-only args * Update other test files to account for positional-only args * Add News entry * Update inspect module and related tests
* bpo-33261: guard access to __code__ attribute in inspect (GH-6448)Jeroen Demeyer2019-04-021-0/+1
|
* bpo-36326: Let inspect.getdoc() find docstrings for __slots__ (GH-12498)Raymond Hettinger2019-03-251-0/+9
|
* bpo-34890: Make iscoroutinefunction, isgeneratorfunction and ↵Pablo Galindo2018-10-261-1/+26
| | | | | | | | | | | isasyncgenfunction work with functools.partial (GH-9903) inspect.isfunction() processes both inspect.isfunction(func) and inspect.isfunction(partial(func, arg)) correctly but some other functions in the inspect module (iscoroutinefunction, isgeneratorfunction and isasyncgenfunction) lack this functionality. This commits adds a new check in the mentioned functions in the inspect module so they can work correctly with arbitrarily nested partial functions.
* bpo-34871: Fix two typos in test_inspect.py (GH-9698)Chih-Hsuan Yen2018-10-041-2/+2
| | | | | | `arg` is misspelled as `agr`. I noticed this when playing with https://bugs.python.org/issue34871 https://bugs.python.org/issue34871
* bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks ↵Vladimir Matveev2018-08-241-2/+12
| | | | (GH-8864)
* bpo-33582: Emit deprecation warning for `formatargspec` (GH-6994)Matthias Bussonnier2018-06-111-4/+6
|
* bpo-33197: Update a error message of invalid inspect.Parameters. (GH-6636)Dong-hee Na2018-05-291-3/+22
|
* bpo-26103: Fix inspect.isdatadescriptor() and a data descriptor definition. ↵Aaron Hall, MBA2018-05-201-1/+56
| | | | | | (GH-1959) Look for '__set__' or '__delete__'.
* bpo-33009: Fix inspect.signature() for single-parameter partialmethods. ↵Yury Selivanov2018-03-061-0/+10
| | | | (GH-6004)
* bpo-32697: Definition order of kwonly params is now guaranteed preserved. ↵larryhastings2018-01-281-0/+47
| | | | | | (#5391) Definition order of kwonly params is now guaranteed preserved.
* bpo-31778: Make ast.literal_eval() more strict. (#4035)Serhiy Storchaka2018-01-041-1/+1
| | | | Addition and subtraction of arbitrary numbers no longer allowed.
* bpo-32265: Classify class and static methods of builtin types. (#4776)Serhiy Storchaka2017-12-151-1/+14
| | | | Add types.ClassMethodDescriptorType for unbound class methods.
* bpo-32297: Few misspellings found in Python source code comments. (#4803)Mike2017-12-141-1/+1
| | | | | | | | * Fix multiple typos in code comments * Add spacing in comments (test_logging.py, test_math.py) * Fix spaces at the beginning of comments in test_logging.py
* bpo-32018: Fix inspect.signature repr to follow PEP 8 (#4408)Dong-hee Na2017-11-151-2/+2
|
* bpo-30639: Lazily compute repr for error (#2132)Thomas Kluyver2017-10-241-0/+8
|
* PEP 553 built-in breakpoint() function (bpo-31353) (#3355)Barry Warsaw2017-10-051-1/+2
| | | Implement PEP 553, built-in breakpoint() with support from sys.breakpointhook(), along with documentation and tests. Closes bpo-31353