This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Direct invocation of `Lib/test/test_typing.py` fails
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, kj, sobolevn
Priority: normal Keywords: patch

Created on 2022-01-17 15:22 by sobolevn, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30641 merged sobolevn, 2022-01-17 15:23
PR 30697 merged sobolevn, 2022-01-19 16:47
PR 30698 closed sobolevn, 2022-01-19 16:56
PR 30707 closed sobolevn, 2022-01-19 19:51
Messages (5)
msg410800 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-17 15:22
Here's the problem:

```
» ./python.exe Lib/test/test_typing.py
........................................................................................................................................................................................................s.....................................................................................................................F.........................................................................................
======================================================================
FAIL: test_special_attrs2 (__main__.SpecialAttrsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_typing.py", line 5068, in test_special_attrs2
    self.assertEqual(
    ^^^^^^^^^^^^^^^^^
AssertionError: '__main__' != 'test.test_typing'
- __main__
+ test.test_typing
```

I think it is a good idea to use the same hack we have in `test_enum.py`: https://github.com/python/cpython/blob/83d544b9292870eb44f6fca37df0aa351c4ef83a/Lib/test/test_enum.py#L34

```python
MODULE = ('test.test_typing', '__main__')[__name__=='__main__']
```

PR is on its way :)
msg410950 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2022-01-19 14:13
New changeset 2792d6d18eab3efeb71e6397f88db86e610541f1 by Nikita Sobolev in branch 'main':
bpo-46416: Allow direct invocation of `Lib/test/test_typing.py` (GH-30641)
https://github.com/python/cpython/commit/2792d6d18eab3efeb71e6397f88db86e610541f1
msg411488 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2022-01-24 16:18
New changeset eaeb99468045b863d2dd3da3e3d1c3c9c78e1254 by Nikita Sobolev in branch '3.10':
[3.10] bpo-46416: Allow direct invocation of `Lib/test/test_typing.py` (GH-30641) (GH-30697)
https://github.com/python/cpython/commit/eaeb99468045b863d2dd3da3e3d1c3c9c78e1254
msg411491 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-01-24 16:33
I noticed that you have been looking into the __main__ block of test modules. Wouldn't it make more sense to just remove the __main__ and have all tests go through regrtest? Everybody should use

   ./python -m regrtest test_typing

or the Windows equivalent to run typing tests.
msg411522 - (view) Author: Nikita Sobolev (sobolevn) * (Python triager) Date: 2022-01-24 22:10
During this work some people have mentioned that they actually use
`'__main__'` for local debugging of tests.
I don't think that I am familiar enough with the existing workflow to make
any educated decision :)

пн, 24 янв. 2022 г. в 19:34, Christian Heimes <report@bugs.python.org>:

>
> Christian Heimes <lists@cheimes.de> added the comment:
>
> I noticed that you have been looking into the __main__ block of test
> modules. Wouldn't it make more sense to just remove the __main__ and have
> all tests go through regrtest? Everybody should use
>
>    ./python -m regrtest test_typing
>
> or the Windows equivalent to run typing tests.
>
> ----------
> nosy: +christian.heimes
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue46416>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90574
2022-01-27 14:44:04sobolevnsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-24 22:10:20sobolevnsetmessages: + msg411522
2022-01-24 16:33:39christian.heimessetnosy: + christian.heimes
messages: + msg411491
2022-01-24 16:18:44kjsetmessages: + msg411488
2022-01-19 19:51:15sobolevnsetpull_requests: + pull_request28903
2022-01-19 16:56:00sobolevnsetpull_requests: + pull_request28896
2022-01-19 16:47:51sobolevnsetpull_requests: + pull_request28895
2022-01-19 14:13:48kjsetnosy: + kj
messages: + msg410950
2022-01-17 15:23:43sobolevnsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28844
2022-01-17 15:22:26sobolevncreate