summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-108303: Move all inspect test files to `test_inspect/` (#109607)Nikita Sobolev2023-10-101-4964/+0
|
* gh-109625: Move _ready_to_import() from test_import to support.import_helper ↵Nikita Sobolev2023-09-211-4/+2
| | | | (#109626)
* gh-108751: Add copy.replace() function (GH-108752)Serhiy Storchaka2023-09-061-4/+61
| | | | | | | | | It creates a modified copy of an object by calling the object's __replace__() method. It is a generalization of dataclasses.replace(), named tuple's _replace() method and replace() methods in various classes, and supports all these stdlib classes.
* gh-108638: Fix tests when _stat extension is missing (#108689)Victor Stinner2023-08-311-6/+22
| | | | Fix test_inspect and test_pydoc when the _stat extension is missing. Skip tests relying on _stat when _stat is missing.
* gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)Nikita Sobolev2023-08-231-1/+1
|
* gh-84805: Autogenerate signature for METH_NOARGS and METH_O extension ↵Serhiy Storchaka2023-08-111-0/+77
| | | | functions (GH-107794)
* gh-107446: Fix test_inspect.test_class_with_method_from_other_module when ↵Tian Gao2023-08-031-0/+3
| | | | | ran multiple times (#107451) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-106727: Add `__module__` check for `inspect.getsource(cls)` (#106968)Tian Gao2023-07-241-0/+28
|
* gh-106727: Make `inspect.getsource` smarter for class for same name ↵Tian Gao2023-07-181-1/+4
| | | | definitions (#106815)
* gh-81283: compiler: remove indent from docstring (#106411)Inada Naoki2023-07-151-2/+33
| | | Co-authored-by: Éric <merwok@netwok.org>
* gh-105080: Fixed inconsistent signature on derived classes (#105217)Tian Gao2023-06-021-0/+18
|
* gh-105042: Disable unmatched parens syntax error in python tokenize (#105061)Lysandros Nikolaou2023-05-301-1/+3
|
* gh-105013: Fix inspect.getsource with parenthesized multiline lambdas (#105021)Pablo Galindo Salgado2023-05-271-0/+16
|
* gh-104955: Fix __release_buffer__ signature (#104956)Jelle Zijlstra2023-05-261-0/+5
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-75367: Fix data descriptor detection in inspect.getattr_static (#104517)Furkan Onder2023-05-161-0/+3
| | | Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-97933: (PEP 709) inline list/dict/set comprehensions (#101441)Carl Meyer2023-05-091-5/+5
| | | | Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-103193: Improve `getattr_static` test coverage (#104286)Alex Waygood2023-05-081-0/+29
|
* gh-103193: cache calls to `inspect._shadowed_dict` in ↵Alex Waygood2023-05-071-0/+22
| | | | | `inspect.getattr_static` (#104267) Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-103556: [inspect.Signature] disallow pos-or-kw params without default ↵Nikita Sobolev2023-04-221-6/+34
| | | | after pos-only with default (#103557)
* gh-103553: Improve `test_inspect`: add more assertions, remove unused (#103554)Nikita Sobolev2023-04-151-15/+9
|
* gh-103406: Modernize pos-only arguments usage in `test_signature` (#103407)Nikita Sobolev2023-04-141-20/+11
|
* gh-102799: use exception instance instead of sys.exc_info() (#102885)Irit Katriel2023-03-311-1/+1
|
* gh-79940: skip `TestGetAsyncGenState` on wasm as it requires working sockets ↵Thomas Krennwallner2023-03-111-1/+3
| | | | | | | | | (GH-102605) Skip `TestGetAsyncGenState` and restoring of the default event loop policy in `test_inspect` if platform lacks working socket support. Fixes #11590 Automerge-Triggered-By: GH:kumaraditya303
* gh-79940: add introspection API for asynchronous generators to `inspect` ↵Thomas Krennwallner2023-03-111-0/+107
| | | | module (#11590)
* gh-102378: don't bother stripping `/` from __text_signature__ (#102379)David Hewitt2023-03-091-16/+7
|
* gh-94912: Adjusted check for non-standard coroutine function marker. (#100935)Carlton Gibson2023-01-111-0/+8
| | | | | | The initial implementation did not correctly identify explicitly marked class instances. Follow up to 532aa4e4e019812d0388920768ede7c04232ebe1
* gh-96127: Fix `inspect.signature` call on mocks (#96335)Nikita Sobolev2023-01-071-0/+19
|
* gh-85267: Improvements to inspect.signature __text_signature__ handling (#98796)Shantanu2022-12-211-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes a couple related changes to inspect.signature's behaviour when parsing a signature from `__text_signature__`. First, `inspect.signature` is documented as only raising ValueError or TypeError. However, in some cases, we could raise RuntimeError. This PR changes that, thereby fixing #83685. (Note that the new ValueErrors in RewriteSymbolics are caught and then reraised with a message) Second, `inspect.signature` could randomly drop parameters that it didn't understand (corresponding to `return None` in the `p` function). This is the core issue in #85267. I think this is very surprising behaviour and it seems better to fail outright. Third, adding this new failure broke a couple tests. To fix them (and to e.g. allow `inspect.signature(select.epoll.register)` as in #85267), I add constant folding of a couple binary operations to RewriteSymbolics. (There's some discussion of making signature expression evaluation arbitrary powerful in #68155. I think that's out of scope. The additional constant folding here is pretty straightforward, useful, and not much of a slippery slope) Fourth, while #85267 is incorrect about the cause of the issue, it turns out if you had consecutive newlines in __text_signature__, you'd get `tokenize.TokenError`. Finally, the `if name is invalid:` code path was dead, since `parse_name` never returned `invalid`.
* gh-94912: Added marker for non-standard coroutine function detection (#99247)Carlton Gibson2022-12-181-0/+45
| | | | | This introduces a new decorator `@inspect.markcoroutinefunction`, which, applied to a sync function, makes it appear async to `inspect.iscoroutinefunction()`.
* gh-100039: enhance __signature__ to work with str and callables (GH-100168)Ethan Furman2022-12-161-0/+32
| | | | | Callables should be either class- or static-methods. Enum now uses the classmethod version to greatly improve the help given for enums and flags.
* gh-83035: handle decorator with nested parens in inspect.getsource (#99654)Carl Meyer2022-12-071-0/+6
|
* gh-74044: inspect.signature for wrappers around decorated bound methods (GH-736)Anton Ryzhov2022-11-101-2/+7
|
* GH-83901: Improve Signature.bind error message for missing keyword-only ↵Frazer McLean2022-10-071-1/+2
| | | | | | params (#95347) Fixes GH-83901
* GH-96073: Fix wild replacement in inspect.formatannotation (#96074)Anh71me2022-10-071-0/+7
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-65961: Do not rely solely on `__cached__` (GH-97990)Brett Cannon2022-10-061-0/+3
| | | Make sure `__spec__.cached` (at minimum) can be used.
* gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (#94050)Mehdi ABAAKOUK2022-06-301-0/+14
| | | | | | | | | The inspect version was not working with unittest.mock.AsyncMock. The fix introduces special-casing of AsyncMock in `inspect.iscoroutinefunction` equivalent to the one performed in `asyncio.iscoroutinefunction`. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-90473: Skip tests that don't apply to Emscripten and WASI (GH-92846)Christian Heimes2022-05-161-1/+4
|
* gh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)Zac Hatfield-Dodds2022-05-031-0/+3
| | | Fixes #92062.
* gh-88116: Enhance the inspect frame APIs to use the extended position ↵Pablo Galindo Salgado2022-04-231-7/+21
| | | | information (GH-91531)
* bpo-29418: Implement inspect.ismethodwrapper and fix inspect.isroutine for ↵Hakan Çelik2022-02-161-3/+43
| | | | | cases where methodwrapper is given (GH-19261) Automerge-Triggered-By: GH:isidentical
* bpo-40280: Address more test failures on Emscripten (GH-31050)Christian Heimes2022-02-051-0/+1
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-46565: `del` loop vars that are leaking into module namespaces (GH-30993)Nikita Sobolev2022-02-031-1/+1
|
* bpo-46103: Fix inspect.getmembers to only get __bases__ from class (GH-30147)Weipeng Hong2022-01-231-0/+5
|
* bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' ↵Weipeng Hong2022-01-211-0/+11
| | | | (GH-30285)
* bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638)Irit Katriel2022-01-181-2/+2
|
* Remove spaces in empty lines (GH-30121)AN Long2021-12-151-1/+1
|
* bpo-27062: add `__all__` to inspect module (GH-30003)Kumar Aditya2021-12-101-0/+3
|
* bpo-30533:Add function inspect.getmembers_static that does not call ↵Weipeng Hong2021-11-301-0/+17
| | | | | | | | | | | | | | | | | | | | | properties or dynamic properties. (#20911) * Add function inspect.getmembers_static that does not call properties or dynamic properties. * update _getmembers args * Update Misc/NEWS.d/next/Library/2020-06-16-18-00-56.bpo-30533.StL57t.rst Co-authored-by: Itamar Ostricher <itamarost@gmail.com> * Update Lib/inspect.py Co-authored-by: Itamar Ostricher <itamarost@gmail.com> * Removes the copy pasted doc string Co-authored-by: Itamar Ostricher <itamarost@gmail.com> Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
* bpo-45406: make inspect.getmodule() return None when getabsfile() raises ↵Irit Katriel2021-11-021-0/+9
| | | | FileNotFoundError (GH-28824)
* bpo-45438: format of inspect.Signature with generic builtins (#29212)Martin Rueckl2021-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>