[issue7559] TestLoader.loadTestsFromName swallows import errors

2016-01-11 Thread Matej Cepl
Changes by Matej Cepl : -- nosy: +mcepl ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/

[issue7559] TestLoader.loadTestsFromName swallows import errors

2015-06-02 Thread R. David Murray
R. David Murray added the comment: It looks to me like this is complete, so closing. -- ___ Python tracker ___ ___ Python-bugs-list mai

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-06 Thread Robert Collins
Robert Collins added the comment: Its backported in unittest2 0.8.0 which is available on pypi for 2.6+ and 3.2+. The changes are large enough that I'd hesitate to backport them in cPython itself. -- ___ Python tracker

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-05 Thread Tim Graham
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-03 Thread R. David Murray
R. David Murray added the comment: I would love that, but I think the fix depends on a feature. Robert will know for sure. -- ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-03 Thread Domen Kožar
Domen Kožar added the comment: Could we backport this one to 3.x and 2.7? It's leads to really bad UX. -- ___ Python tracker ___ ___ Py

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 708b2e656c1d by Robert Collins in branch 'default': Close #7559: ImportError when loading a test now shown as ImportError. https://hg.python.org/cpython/rev/708b2e656c1d -- nosy: +python-dev resolution: -> fixed stage: patch review -> resol

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-27 Thread Robert Collins
Robert Collins added the comment: I've updated the patch to try and address the niggling clarity issues from the review. Please let me know what you think (and if I hear nothing I'll commit it as-is since the review was still ok). -- Added file: http://bugs.python.org/file37045/issue75

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-23 Thread Robert Collins
Robert Collins added the comment: Thanks for the review, updated patch here - I'll let this sit for a day or two for more comments then commit it Monday. -- Added file: http://bugs.python.org/file37002/issue7559.patch ___ Python tracker

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-23 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +berker.peksag ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-19 Thread Robert Collins
Robert Collins added the comment: Patch polished up and updated - ready for review IMO. -- ___ Python tracker ___ ___ Python-bugs-list

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-10-19 Thread Robert Collins
Changes by Robert Collins : Added file: http://bugs.python.org/file36974/issue7559.patch ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-09 Thread Robert Collins
Robert Collins added the comment: Raced with your comment. Great - and thanks! -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-09 Thread Robert Collins
Robert Collins added the comment: This is what I see in my tree: E == ERROR: test_os (unittest.loader.ModuleImportFailure) -- Traceback (most recent call last):

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-09 Thread R. David Murray
R. David Murray added the comment: OK, with both patches applied the output looks good. With a bit of luck I'll have some time to actually review the patches in a couple of hours. -- ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-09 Thread Robert Collins
Robert Collins added the comment: You may need to apply the patch from http://bugs.python.org/issue19746 first as well - I was testing with both applied. -- ___ Python tracker __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-09 Thread R. David Murray
R. David Murray added the comment: Thanks for tackling this. It's been bugging me almost daily this past week, but as usual when this bug is in my face I had no time to actually work on a fix. I applied this patch to default, put an invalid import in test_os, and this is the result: rdmurr

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-08 Thread Robert Collins
Robert Collins added the comment: Ok, here is an implementation that I believe covers everything Michael wanted. I examined the other patches, and can rearrange my implementation to be more like them if desired - but at the heart of this this bug really has two requested changes: - deferred r

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-09-08 Thread Robert Collins
Robert Collins added the comment: I've just put a patch up for the related issue http://bugs.python.org/issue19746 I'll poke at this one briefly now, since I'm across the related code. -- ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-06-30 Thread Mark Lawrence
Mark Lawrence added the comment: Note that #8297 referenced in msg102236 is closed see changeset d84a69b7ba72. -- ___ Python tracker ___ __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-06-30 Thread Mark Lawrence
Mark Lawrence added the comment: Note that this issue is referred to from #15358. -- nosy: +BreamoreBoy versions: +Python 3.5 -Python 3.4 ___ Python tracker ___ __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-06-12 Thread vila
Changes by vila : -- nosy: +vila ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-04-16 Thread Zachary Ware
Changes by Zachary Ware : -- nosy: +zach.ware ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-04-01 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-03-27 Thread Domen Kožar
Domen Kožar added the comment: One relevant use case is the following: https://github.com/Pylons/venusian/issues/23 Here the module is supposed to raise an ImportError. -- ___ Python tracker __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-03-27 Thread Michael Foord
Michael Foord added the comment: My preferred fix is to wrap "an exception during import" as a test that fails instead of an AttributeError. This would definitely be a new feature rather than a bugfix - so it could only be in 3.4. It could be made available to Python 2.7 through the unittest2

[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-03-26 Thread Domen Kožar
Domen Kožar added the comment: What can I do to put this forward? It's still an issue in py2.7 -- nosy: +iElectric ___ Python tracker ___ _

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-11-12 Thread Eric Snow
Changes by Eric Snow : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.or

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-09-18 Thread Julian Berman
Changes by Julian Berman : -- nosy: +Julian ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-04 Thread R. David Murray
R. David Murray added the comment: Ah, yes, I wasn't clear. Sorry. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-04 Thread Chris Jerdonek
Chris Jerdonek added the comment: That sounds fine. I just got the sense from above that there was a desire to call invalidate_caches() as few times as possible. And yes, I agree only before is necessary. I had just taken what you said above literally (that "[the cache] should be reset by t

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-04 Thread R. David Murray
R. David Murray added the comment: That would probably be OK, but I don't see why clearing the cache in those same methods (that create directories on the path) would be any harder. (It isn't necessary to clear the cache *afterward*, only before, as far as I can see, since the case of a dire

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-04 Thread Chris Jerdonek
Chris Jerdonek added the comment: Because we don't know if the rest of the test code will adhere to this, we might want to consider clearing the cache before each test as well. Alternatively, we could avoid having to call importlib.invalidate_caches() at all (and having to think about for whi

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-03 Thread R. David Murray
R. David Murray added the comment: OK, let's just do it in the individual test, then. -- ___ Python tracker ___ ___ Python-bugs-list m

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-03 Thread Brett Cannon
Brett Cannon added the comment: Not sure what DirsOnSysPath is, but I have been only calling importlib.invalidate_caches() as needed in order to not slow down tests needlessly. And as for detecting an environment change as necessary, that's essentially impossible since it's only needed if so

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-03 Thread R. David Murray
R. David Murray added the comment: Thanks for figuring that out. And no, it doesn't matter if it is importlib.load_module or __import__, since both are provided by importlib now and both use the cache. It's an interesting question where the cache clear should go. I *think* it should go in

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-02 Thread Chris Jerdonek
Chris Jerdonek added the comment: Thanks. It looks like the issue with the latest patch is caused by side effects of calling importlib.import_module(). Working from the patch, I got it to the point where inserting the following four lines somewhere in the code-- try: importlib.i

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-06-01 Thread R. David Murray
R. David Murray added the comment: I updated the tests to Python3, and attempted to replicate the fix using the new importlib qualname support. Even if it had worked, this would not have finished the patch, since Michael wants to generate a failing test instead of raising the import error.

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-04-21 Thread Michael Foord
Michael Foord added the comment: My favoured fix is to catch the exception and generate a failing test that re-raises the *original exception* (with traceback) when run. That way a single failing module doesn't kill a whole test run (although it does mean later feedback about misspelt imports

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-04-21 Thread R. David Murray
R. David Murray added the comment: Does fix for issue 1559549 (and the fact that importlib is in) allow for a cleaner fix for this? I've been putting off dealing with this issue in the expectation that it would. To answer the question: the fixed API can go in 3.3. If we fix this in earlier

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-04-20 Thread Chris Jerdonek
Chris Jerdonek added the comment: I'm still getting hit with this. In what versions is it okay for us to fix the bad API, as Michael suggested? -- ___ Python tracker ___ __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2012-02-05 Thread Éric Araujo
Changes by Éric Araujo : -- versions: +Python 3.3 -Python 2.6, Python 3.1 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue7559] TestLoader.loadTestsFromName swallows import errors

2011-07-14 Thread Michael Foord
Michael Foord added the comment: My thinking on this has evolved a bit. Changing an import error into an attribute error is just a bad api. We should just fix the bad api. -- ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2011-07-13 Thread R. David Murray
R. David Murray added the comment: Michael, if you have no objection to this patch I'm willing to commit it. -- ___ Python tracker ___ ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2011-07-12 Thread Alex Garel
Alex Garel added the comment: May I just add that I also ran into this and give my +1 for any fix :-) -- nosy: +alexgarel ___ Python tracker ___ _

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-14 Thread Michael Foord
Changes by Michael Foord : -- assignee: cjerdonek -> michael.foord ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-13 Thread Chris Jerdonek
Changes by Chris Jerdonek : -- assignee: michael.foord -> cjerdonek ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-13 Thread Daniel Diniz
Changes by Daniel Diniz : -- stage: unit test needed -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-10 Thread Chris Jerdonek
Chris Jerdonek added the comment: Patch update: added unit test to cover replacing __import__, incorporated R. David Murray's suggestion to use test_support.test_cwd(), and overall code clean-up. Also uploaded as Patch 3 to-- http://codereview.appspot.com/810044/show -- Added file:

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-09 Thread Chris Jerdonek
Chris Jerdonek added the comment: > I think you can simplify them a bit. For example, you can use assertRaises. Actually, assertRaises doesn't seem to permit checking error text. That may be one reason why try-except-else is being used instead throughout. --

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-09 Thread Chris Jerdonek
Chris Jerdonek added the comment: Thanks for your suggestions on the test code. I will do that. It seems like the hard-coded approach would be more brittle. For example, if someone wants to replace __import__ with their own, e.g. old__import__ = __builtins__.__import__ def __my_logging_imp

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-08 Thread R. David Murray
R. David Murray added the comment: Thank you very much for those tests. I think you can simplify them a bit. For example, you can use assertRaises. You also might be able to use the test_support.temp_cwd context manager in your context manager, even though you don't need the cwd part. I've

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-08 Thread Chris Jerdonek
Chris Jerdonek added the comment: The new unit tests pass with this patch (minor clean-up still needed). -- Added file: http://bugs.python.org/file16822/_patch-7559-5.diff ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-08 Thread Chris Jerdonek
Chris Jerdonek added the comment: Four failing unit tests (context code can use clean-up). -- Added file: http://bugs.python.org/file16819/_patch-7559-4-unittests.diff ___ Python tracker ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-08 Thread Chris Jerdonek
Chris Jerdonek added the comment: FYI, there seems to be a bug in the code cited above: http://twistedmatrix.com/trac/browser/trunk/twisted/python/reflect.py#L382 For example, _importAndCheckStack('package.subpackage.module') raises _NoModuleFound in the following scenario: package/subpackage

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-07 Thread Chris Jerdonek
Chris Jerdonek added the comment: Thanks, David. Sorry about that. The test probably requires one additional level of nesting so that "parts_copy" is not False: +if not parts_copy or not module_not_found: raise -- ___

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-07 Thread R. David Murray
R. David Murray added the comment: The unit test passes on trunk for me without the fix applied. -- ___ Python tracker ___ ___ Python-

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-06 Thread Chris Jerdonek
Chris Jerdonek added the comment: Rietveld link: http://codereview.appspot.com/810044/show This patch changes unittest.TestLoader.loadTestsFromName() so that ImportErrors will bubble up when importing from a module with a bad import statement. Before the method raised an AttributeError. The

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-04 Thread Chris Jerdonek
Chris Jerdonek added the comment: This patch implements Michael's suggestion (but not the ErrorHolder part): http://bugs.python.org/issue7559#msg97462 The unit tests all pass with no change. If this approach looks good to you, I can add a unit test to the patch that checks that this bug has

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-04-03 Thread Chris Jerdonek
Chris Jerdonek added the comment: > I think in both cases the error text should state not just what module was > being imported but also what module was being imported from FYI, I filed the following report partly in response to some of the comments I made above: http://bugs.python.org/issue

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-03-28 Thread Chris Jerdonek
Chris Jerdonek added the comment: I was also hit by this today. For the sake of clarity, I will restate two of the scenarios that have been mentioned in this discussion: (1) An ImportError raised whilst importing a module (original issue) (2) A sub-module not existing. I think the error text

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-01-09 Thread Michael Foord
Changes by Michael Foord : -- assignee: -> michael.foord ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-01-09 Thread Michael Foord
Michael Foord added the comment: I'm unhappy with a straight change in behaviour because it will break code that is currently catching AttributeError. A slightly less invasive change would be to raise an AttributeError if the module doesn't exist, otherwise letting the original error propagat

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-01-09 Thread Michael Foord
Michael Foord added the comment: Wouldn't this be a backwards incompatible change of tested behaviour though? -- ___ Python tracker ___ __

[issue7559] TestLoader.loadTestsFromName swallows import errors

2010-01-03 Thread Salman Haq
Salman Haq added the comment: Hope everyone had a good new year's. I've attached an updated patch which adds a new unittest, test_loadTestsFromNames__badimport. Both the new unittests can use better documentation, hopefully one of you can help me with that. -- Added file: http://bug

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-28 Thread Salman Haq
Salman Haq added the comment: I'm attaching a patch (against trunk) which I think is a step in the right direction but I could use some feedback. This patch modifies 'loadTestsFromName()' so that it saves and re-raises an ImportError. Further this patch introduces a new unittest (test_loadTes

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-26 Thread Salman Haq
Salman Haq added the comment: Line 348 in trunk/Lib/test/test_unittest.py has a test case to specifically test that in the described situation, the test returns an AttributeError. Should this test be changed so that it passes if the exception is in fact an ImportError? def test_loadTestsFrom

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread Robert Collins
Robert Collins added the comment: I'm scratching an itch at the moment, I just noted this in passing ;) I'm partial to the 'turn it into a fake test case' approach, its what I would do if I get to it first. -- ___ Python tracker

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread Michael Foord
Michael Foord added the comment: I'll try and look at both these issues in the next few days unless one of you beats me to it. :-) -- ___ Python tracker ___ _

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread R. David Murray
R. David Murray added the comment: Note: this problem is similar in some ways to issue 5230, and a similar solution might be appropriate (or might not :). -- ___ Python tracker _

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread R. David Murray
R. David Murray added the comment: Thank you. I can reproduce this on trunk as well. I'm leaving stage set to test needed because we need to turn this into a unit test. -- keywords: +easy versions: +Python 2.7, Python 3.1, Python 3.2 ___ Python tra

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread Robert Collins
Robert Collins added the comment: mkdir thing touch thing/__init__.py echo "import blert" > thing/test_foo.py python -m unittest thing.test_fooTraceback (most recent call last): File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main "__main__", fname, loader, pkg_name) File

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread R. David Murray
R. David Murray added the comment: Could you provide a more complete recipe for reproducing the problem, please? I created a test_foo.py containing 'import blert', and running python -m unittest test_foo does not mask the import error for blert in loadTestsFromName: ... File "/usr/lib/python

[issue7559] TestLoader.loadTestsFromName swallows import errors

2009-12-21 Thread Robert Collins
New submission from Robert Collins : Say I have a test module test_foo, which fails to import with ImportError. A reason for this might be a misspelt import in that module. TestLoader().loadTestsFromName swallows the import error and instead crashes with: File "/usr/lib/python2.6/unittest.py",