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: test_fork1 cannot be run directly: ./python Lib/test/test_fork1.py
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: felippemr, martin.panter, python-dev, vstinner, zach.ware
Priority: normal Keywords: easy, patch

Created on 2015-12-04 10:54 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mywork.patch felippemr, 2015-12-04 20:31 Patch for issue review
mywork.patch felippemr, 2015-12-05 00:27 Patch for issue review
Messages (13)
msg255856 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-12-04 10:54
haypo@smithers$ ./python Lib/test/test_fork1.py 
Traceback (most recent call last):
  File "Lib/test/test_fork1.py", line 111, in <module>
    unittest.main()
NameError: name 'unittest' is not defined

According to pyflakes, the error "undefined name 'unittest'" is found in:

- test_fork1
- test_list
- test_pyclbr
- test_telnetlib
- test_tuple
- test_userdict
- test_userlist
- test_wait4

I put the "easy" flag to give a simple issue to newcomers in Python ;-)

Please check other Python version: 2.7 and 3.5. I'm too lazy to check myself :-D

See issue the issue #25783 which is similar.
msg255872 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-12-04 17:58
Hmm, oops.  This would be a result of 3aec776fc796, which was applied only to the default before 3.5 was branched.
msg255875 - (view) Author: Felippe da Motta Raposo (felippemr) * Date: 2015-12-04 19:35
I'd like to fix it!

How am I supposed to start?
msg255878 - (view) Author: Felippe da Motta Raposo (felippemr) * Date: 2015-12-04 20:31
I did it!

Can you please take a look at it?
msg255882 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-12-04 20:47
> How am I supposed to start?

Can you please check if the branch 3.5 is impacted?
msg255884 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-12-04 21:03
STINNER Victor added the comment:
> Can you please check if the branch 3.5 is impacted?

It is.
msg255910 - (view) Author: Felippe da Motta Raposo (felippemr) * Date: 2015-12-05 00:27
SilentGhost suggested that I should change all occurrences of `TestCase`, on both `test_telnetlib` and `test_pyclbr`, by `unittest.TestCase`. This patch has these changes.
msg255912 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-05 01:20
Either patch looks good to me. I don’t have a strong opinion about unittest.TestCase. I left a comment about adding the module=... back in test_pyclbr.
msg255914 - (view) Author: Felippe da Motta Raposo (felippemr) * Date: 2015-12-05 02:08
Martin Panter added the comment:
 > I left a comment about adding the module=... back in test_pyclbr.

I had to put it because `test_others` was failing:
(test output)
```
l1=['TestCase']
l2=['unittest.TestCase']
ignore={'object'}
class=<class 'test.test_pyclbr.PyclbrTest'>
FAIL

======================================================================
FAIL: test_others (__main__.PyclbrTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_pyclbr.py", line 169, in test_others
    cm('test.test_pyclbr')
  File "Lib/test/test_pyclbr.py", line 102, in checkModule
    self.assertListEq(real_bases, pyclbr_bases, ignore)
  File "Lib/test/test_pyclbr.py", line 27, in assertListEq
    self.fail("%r missing" % missing.pop())
AssertionError: 'unittest.TestCase' missing
```
msg255922 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-12-05 05:19
I'd rather leave things as they were, just add ', main as unittest_main' to the existing 'from unittest import TestCase' and change the call at the end from 'unittest.main()' to 'unittest_main()'.

Felippe, have you signed a contributor agreement?  If not, it can be found here:

   https://www.python.org/psf/contrib/contrib-form/
msg255923 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-12-05 05:34
New changeset a54ee6a65f10 by Zachary Ware in branch '3.5':
Issue #25795: Fix several tests to run independently.
https://hg.python.org/cpython/rev/a54ee6a65f10

New changeset 401459dca320 by Zachary Ware in branch 'default':
Closes #25795: Merge with 3.5
https://hg.python.org/cpython/rev/401459dca320
msg255924 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-12-05 05:35
I made the change to test_pyclbr that I mentioned and committed it.  Thanks, Fellipe!
msg255943 - (view) Author: Felippe da Motta Raposo (felippemr) * Date: 2015-12-05 11:34
Thank you!
History
Date User Action Args
2022-04-11 14:58:24adminsetgithub: 69981
2015-12-05 11:34:05felippemrsetmessages: + msg255943
2015-12-05 05:35:31zach.waresetmessages: + msg255924
2015-12-05 05:34:20python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg255923

resolution: fixed
stage: patch review -> resolved
2015-12-05 05:19:19zach.waresetmessages: + msg255922
2015-12-05 02:08:43felippemrsetmessages: + msg255914
2015-12-05 01:20:37martin.pantersetnosy: + martin.panter

messages: + msg255912
stage: needs patch -> patch review
2015-12-05 00:27:20felippemrsetfiles: + mywork.patch

messages: + msg255910
2015-12-04 21:03:39zach.waresetmessages: + msg255884
2015-12-04 20:47:35vstinnersetmessages: + msg255882
2015-12-04 20:31:05felippemrsetfiles: + mywork.patch
keywords: + patch
messages: + msg255878
2015-12-04 19:35:18felippemrsetnosy: + felippemr
messages: + msg255875
2015-12-04 17:59:23zach.waresettitle: test_fork1 cannot be run directly: ./pyhon Lib/test/test_fork1.py -> test_fork1 cannot be run directly: ./python Lib/test/test_fork1.py
2015-12-04 17:58:32zach.waresettype: behavior
stage: needs patch
messages: + msg255872
versions: + Python 3.5
2015-12-04 11:14:33serhiy.storchakasetnosy: + zach.ware
2015-12-04 10:54:55vstinnercreate