Re: [Python-Dev] cpython (3.3): #16919: test_crypt now works with unittest test discovery. Patch by Zachary
On Fri, 11 Jan 2013 04:20:21 +0100 (CET)
ezio.melotti
diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,7 +1,11 @@ from test import support import unittest
-crypt = support.import_module('crypt') +def setUpModule(): + # this import will raise unittest.SkipTest if _crypt doesn't exist, + # so it has to be done in setUpModule for test discovery to work + global crypt + crypt = support.import_module('crypt')
Yikes. Couldn't unittest support SkipTest being raised at import instead? setUpModule is an ugly way to do this. Regards Antoine.
On Fri, 11 Jan 2013 08:11:00 +0100, Antoine Pitrou
On Fri, 11 Jan 2013 04:20:21 +0100 (CET) ezio.melotti
wrote: diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,7 +1,11 @@ from test import support import unittest
-crypt = support.import_module('crypt') +def setUpModule(): + # this import will raise unittest.SkipTest if _crypt doesn't exist, + # so it has to be done in setUpModule for test discovery to work + global crypt + crypt = support.import_module('crypt')
Yikes. Couldn't unittest support SkipTest being raised at import instead? setUpModule is an ugly way to do this.
Indeed. Almost every use of support.import_module will have this issue, so fixing unittest is by far the better fix. --David
On Fri, Jan 11, 2013 at 8:37 AM, R. David Murray
On Fri, 11 Jan 2013 08:11:00 +0100, Antoine Pitrou
wrote: On Fri, 11 Jan 2013 04:20:21 +0100 (CET) ezio.melotti
wrote: diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -1,7 +1,11 @@ from test import support import unittest
-crypt = support.import_module('crypt') +def setUpModule(): + # this import will raise unittest.SkipTest if _crypt doesn't exist, + # so it has to be done in setUpModule for test discovery to work + global crypt + crypt = support.import_module('crypt')
Yikes. Couldn't unittest support SkipTest being raised at import instead? setUpModule is an ugly way to do this.
Indeed. Almost every use of support.import_module will have this issue, so fixing unittest is by far the better fix.
Bug filed: http://bugs.python.org/issue16935
participants (3)
-
Antoine Pitrou
-
Brett Cannon
-
R. David Murray