[issue45865] Old syntax in unittest
Adam Johnson added the comment: Okay, I updated the PR to only remove inheritance from object. Should I reopen the ticket? (Not sure of the etiquette.) Perhaps I could later submit a second patch for use of `super()`, and so on? -- ___ Python tracker <https://bugs.python.org/issue45865> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23882] unittest discovery doesn't detect namespace packages when given no parameters
Adam Johnson added the comment: I just reported https://bugs.python.org/issue45864 , and closed as duplicate of this. -- nosy: +adamchainz ___ Python tracker <https://bugs.python.org/issue23882> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45864] unittest does not discover tests in PEP420 packages
Change by Adam Johnson : -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue45864> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45864] unittest does not discover tests in PEP420 packages
Adam Johnson added the comment: It's exactly that ticket. I missed that when searching for duplicates - I only searched for "pep420" and not "namespace packages". Mea culpa. -- resolution: -> duplicate ___ Python tracker <https://bugs.python.org/issue45864> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45865] Old syntax in unittest
Change by Adam Johnson : -- keywords: +patch pull_requests: +27934 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29698 ___ Python tracker <https://bugs.python.org/issue45865> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45865] Old syntax in unittest
New submission from Adam Johnson : I often browse the unittest code in order to write extensions. It still uses some Python 2-isms like classes inheriting from object, it would be nice to clean that up. -- components: Tests messages: 406757 nosy: adamchainz priority: normal severity: normal status: open title: Old syntax in unittest type: enhancement ___ Python tracker <https://bugs.python.org/issue45865> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45864] unittest does not discover tests in PEP420 packages
New submission from Adam Johnson : unittest's test discovery does not descend into directories without `__init__.py`. This avoids discovering test modules that are otherwise valid and importable, after PEP 420. I've seen this more than once where there were valid looking test files not being discovered, and they bit rot. The tests had been run individually when created but never again. (I created [flake8-no-pep420](https://pypi.org/project/flake8-no-pep420/) to avoid this problem on my projects.) For example, take this directory structure: ``` $ tree . └── tests └── test_thing.py 1 directory, 1 file $ cat tests/test_thing.py 1/0 ``` It's valid to import the naughty file, which crashes: ``` $ python -c 'import tests.test_thing' Traceback (most recent call last): File "", line 1, in File "/.../tests/test_thing.py", line 1, in 1/0 ZeroDivisionError: division by zero ``` But unittest does not discover it: ``` $ python -m unittest -- Ran 0 tests in 0.000s OK ``` But, after creating an empty `__init__.py`, the tests doth fail: ``` $ touch tests/__init__.py $ python -m unittest E == ERROR: tests.test_thing (unittest.loader._FailedTest) -- ImportError: Failed to import test module: tests.test_thing Traceback (most recent call last): File "/.../unittest/loader.py", line 436, in _find_test_path module = self._get_module_from_name(name) File "/.../unittest/loader.py", line 377, in _get_module_from_name __import__(name) File "/.../tests/test_thing.py", line 1, in 1/0 ZeroDivisionError: division by zero -- Ran 1 test in 0.000s FAILED (errors=1) ``` -- components: Tests messages: 406756 nosy: adamchainz priority: normal severity: normal status: open title: unittest does not discover tests in PEP420 packages type: behavior ___ Python tracker <https://bugs.python.org/issue45864> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38839] Some unused functions in test suite
New submission from Adam Johnson : Whilst developing a new unused function check for flake8 ( https://github.com/PyCQA/pyflakes/pull/485 ) I ran it against the CPython source code and found some uncalled functions. -- messages: 356919 nosy: adamchainz priority: normal pull_requests: 16745 severity: normal status: open title: Some unused functions in test suite type: enhancement ___ Python tracker <https://bugs.python.org/issue38839> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Regular expression for not-group
You want to use negative lookahead eg.\.(?!py)it matches only if the characters ahead in the regex don't match the pattern in the brackets. http://docs.python.org/lib/re-syntax.html (about halfway down the page)On 15 Jun 2006 14:11:39 -0700, Chris Lasher [EMAIL PROTECTED] wrote: Is it possible to write a regular _expression_ such that a match isfound provided the string does not match a group in the regex? Let megive a concrete example.Suppose I want to find a match to any filename that does not end in .py, (ignoring the obvious use of the .endswith('.py') string method).I tried the things that were obvious to me, none of which worked.\.^(py)\.(^py)\.[^p][^y]The last one deceived me at first because it will match spam.spam,but not spam.parrot. I'm a bit stumped at this point. If this can bedone with a regular _expression_, I'd love to know how, and even if itcan't be, that would be very helpful to know, too. Many thanks in advance,Chris--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
module with __call__ defined is not callable?
Hi All.I was wondering why defining a __call__ attribute for a module doesn't make it actually callable.I don't have any reason for doing so, I was just wondering if it worked, and found out it didn't.$ cat mod.pyTest callable moduledef __call__(): return in mod.__call__ import mod mod()Traceback (most recent call last): File stdin, line 1, in ?TypeError: 'module' object is not callable mod.__call__()'in mod.__call__'Thanks for any replies, Adam. -- http://mail.python.org/mailman/listinfo/python-list
Re: module with __call__ defined is not callable?
Thanks for you answer.I was under the impression that you could tack methods onto an object at any time, your example almost works with old style classes and would with a function instead of a method. class A: ... def __init__(self):... self.__call__ = A.hello... def hello(self):... print Hello, world!... a = A() a()Traceback (most recent call last): File stdin, line 1, in ?TypeError: unbound method hello() must be called with A instance as first argument (got nothing instead) a(a)Hello, world!So now all I need to know is why now with new style classes the special functions need to be defined on the class instead of attached to the instance at any time. On 08/02/06, Delaney, Timothy (Tim) [EMAIL PROTECTED] wrote: adam johnson wrote: Hi All. I was wondering why defining a __call__ attribute for a module doesn't make it actually callable.For the same reason that the following doesn't workclass A (object): def __init__(self):self.__call__ = A.hellodef hello (self):print 'Hello, world!'a = A()a()Traceback (most recent call last): File D:\Python\modules\testclasscall.py, line 10, in ?a()TypeError: 'A' object is not callableThe __call__ attribute must be defined on the class (or type) - not onthe instance. A module is an instance of type 'module'. Tim Delaney--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list