[issue17457] Unittest discover fails with namespace packages and builtin modules

2014-06-10 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Can we close this? The feature already landed in Python 3.4.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2014-06-10 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2014-03-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 57cb8a6e8f10 by R David Murray in branch 'default':
whatsnew: unittest discover works on namespace packages (#17457).
http://hg.python.org/cpython/rev/57cb8a6e8f10

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-25 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Sorry for the delay. Here's a minimal doc patch. I don't excel at writing 
documentation, it's not quite my strong point, so feel free to modify anything 
you seem fit.

--
Added file: http://bugs.python.org/file32842/namespace.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-23 Thread Michael Foord

Michael Foord added the comment:

I'm going to commit this so we get it in before the feature freeze. It sounds 
like the remaining issue is minor and we can resolve it in the betas.

Note that if we attempt discovery from a namespace package and fail we should 
create a ModuleImportError test case to report the problem and *not* bomb out 
of test collection.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-23 Thread Michael Foord

Michael Foord added the comment:

Need doc updates

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d2e5b74e2d18 by Michael Foord in branch 'default':
Issue 17457: extend test discovery to support namespace packages
http://hg.python.org/cpython/rev/d2e5b74e2d18

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-22 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Hello! Attached patch which uses ModuleSpec, tested with 
http://hg.python.org/features/pep-451/ repo.

--
Added file: http://bugs.python.org/file32771/unittest_discovery_spec2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-22 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Added patch which addresses Eric's comments. It contains a situation which I'm 
not so happy, mostly due to not knowing in depth (or at least at a comfortable 
level) the import mechanics: in the AttributeError except handler, if the spec 
can't be determined and the module is not built-in, a TypeError is raised to 
notice the user that discovery can't be done for that particular package. 
Probably this situation (no __file__, no __spec__ and no built-in) is common, 
but I can't think right now at another way of solving it.

--
Added file: http://bugs.python.org/file32783/unittest_discover.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-18 Thread Eric Snow

Eric Snow added the comment:

I left a review relative to the use of the _path attribute (which shouldn't be 
used).

--
nosy: +eric.snow

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-18 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Eric, thank you for your comment! I modified the patch to check for __path__ 
instead, is this a safe enough check for this use case? Since ModuleSpec isn't 
landed yet, I didn't use your __spec__ example.

--
Added file: http://bugs.python.org/file32697/unittest-17457-3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-18 Thread Eric Snow

Eric Snow added the comment:

Sorry for any confusion, Claudiu.  the_module.__path__ only indicates that the 
module is a package.  So until you can take advantage of PEP 451, you're stuck 
with the _path check (or several other unappealing hack) on line 224 of 
unittest-17457-3.patch.

However, the use of __path__ on line 226 is correct now. :)  Thanks for 
changing that.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-17 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Attached new patch, which addresses Ezio's comments on Rietveld.

--
Added file: http://bugs.python.org/file32664/unittest-17457-2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-17 Thread Michael Foord

Michael Foord added the comment:

I do want to get this into 3.4. The logic is non-trivial though, so I need to 
understand it before I can add it to discovery. It certainly *looks* good.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-16 Thread Ezio Melotti

Ezio Melotti added the comment:

I left a couple of comments on rietveld.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-11-10 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Michael, is any chance for this to go into Python 3.4? I would love to make any 
changes necessary in order for this to happen.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-07-10 Thread Michael Foord

Michael Foord added the comment:

I'd like to review this properly before committing it. I agree it solves a real 
problem and your new patch looks good.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-07-09 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Hello. Can I do something to move this issue forward?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-03-23 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti, michael.foord
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-03-23 Thread Michael Foord

Michael Foord added the comment:

Thanks for the report and the patch. Good catch!

It will need looking over as it's not immediately obvious to me it's correct. 

In the code that checks the loader path, does it iterate over every member of 
the namespace path - even directories that aren't in the path being searched?

--
assignee:  - michael.foord

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-03-23 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Yes, it iterates over every member of the namespace path. The new attached 
patch fixes this behaviour, by checking that each loader path starts with 
top_level_dir when set_implicit_top is False (if set_implicit_top is True, 
top_level_dir is irrelevant, start_dir will be the package name).

 Also, with the original patch there were other issues:
  1. if no tests were found for the namespace package, the same failure as 
before would have occurred at the lines:

  +if not tests:
  +tests = list(self._find_tests(start_dir, pattern))

  2. it iterated every subfolder, by dropping the check for __init__.py. To fix 
this, I added a new keyword argument to _find_tests, `namespace` which defaults 
to False. If it is True, then we are checking a namespace package and 
subfolders will be checked even if they don't have a __init__.py file.

--
Added file: http://bugs.python.org/file29556/unittest-17457.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-03-18 Thread Popa Claudiu

New submission from Popa Claudiu:

There is a problem with unittest discovering and namespace packages. Given the 
following folder structure, where a namespace package X lies, the following 
command fails with the following error:

-testbug
   - flufl (namespace package with some tests in it, importable with __import__)
  - test_a.py
  - test_b.py


C:\py -3 -m unittest discover flufl
Traceback (most recent call last):
  File C:\Python33\lib\runpy.py, line 160, in _run_module_as_main
__main__, fname, loader, pkg_name)
  File C:\Python33\lib\runpy.py, line 73, in _run_code
exec(code, run_globals)
  File C:\Python33\lib\unittest\__main__.py, line 12, in module
main(module=None)
  File C:\Python33\lib\unittest\main.py, line 124, in __init__
self.parseArgs(argv)
  File C:\Python33\lib\unittest\main.py, line 144, in parseArgs
self._do_discovery(argv[2:])
  File C:\Python33\lib\unittest\main.py, line 242, in _do_discovery
self.test = loader.discover(start_dir, pattern, top_level_dir)
  File C:\Python33\lib\unittest\loader.py, line 205, in discover
start_dir = os.path.abspath(os.path.dirname((the_module.__file__)))
AttributeError: 'module' object has no attribute '__file__'

This happens because TestLoader.discover assumes that the given dotted package 
name has the attribute __file__, which seems to not be true in the case of 
namespace packages. The same error occurs when giving to `discover` a builtin 
module.
The attached patch tries naively to solve this issue, but it assume in 
TestLoader._find_tests that it should iterate over all subfolders (the 
commented line from the patch), unlike the previous way of checking the 
presence of __init__.py file.
Thanks in advance for your response.

--
components: Library (Lib)
files: unittest.patch
keywords: patch
messages: 184450
nosy: Popa.Claudiu
priority: normal
severity: normal
status: open
title: Unittest discover fails with namespace packages and builtin modules
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29441/unittest.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17457] Unittest discover fails with namespace packages and builtin modules

2013-03-18 Thread Eric V. Smith

Changes by Eric V. Smith e...@trueblade.com:


--
nosy: +eric.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17457
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com