-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config.testMatch is a bogus regex #11
Comments
I'm just checking out nose for the first time today and this immediately stuck out since its in the intro documentation. Google Code Info: |
It's been more than a year since this issue was reported! One could have an impression that the testing framework is poorly tested itself ) Would you at least fix the documentation, please: Any function or class that matches the configured testMatch regular expression ((?:^|[\b_.-])[Tt]est) by default – that is, has test or Test at a word boundary or following a - or _) This is not true for the reasons nicely described above (also "following a -" already is a word boundary) I understand that having spaces in a filename is not a common practice (I wouldn't do that myself without some proper reason), but it's not so difficult to keep at least the tutorial part of the documentation clean, is it? ;) I'd suggest replacing the regexp with something like (?:^|[_.-])[Tt]est if you want to be backwards-compatible and dropping 'word boundary' from the docs. Google Code Info: |
A patch that makes the regex work correctly and match the docs would see this fixed for 1.1, otherwise it's unlikely to be fixed before the following release. Google Code Info: |
It's worth noting also that the fontification of the docs reveals this regexp surrounded by parens, but the closing paren is rendered in code font, so I assumed it was part of the regexp and copied it only to have re tell me it's an invalid regexp Google Code Info: |
The current docs on packages.python.org does not contain an escape character before the b in the regex. This is an obvious error that confused the hell out of me for about half an hour while I tried to figure out why nose would conceivably search for functions/classes/etc. with "btest" in them. In addition, is there some way that the packages.python.org docs could be purged, if they are not the official home anymore? Having the out of date documentation on what looks like such an official site is really, really confusing. Google Code Info: |
This issue is a serious stumbling block. For instance "runTest" is used, but not "runMyTest". Super confusing! |
What version of the product are you using? On what operating system?
the default source branch as of 2010-04-30
config.py line 145 is:
self.testMatch = re.compile(r'(?:^|[\b_.%s-])[Tt]est' % os.sep)
A minor point first: dot in a character class is always literal, for the obvious reason; no need to escape it.
The main point: \b in a character class is a backspace, not a word boundary. That's why you've got all the
apparently-but-not-actually redundant stuff in there that \b ought to be matching: the ^ anchor, dot,
hyphen, os.sep. The only thing that \b wouldn't cover is underscore.
The pattern works adequately, but not as expected, since \b isn't really doing its job. I believe that the
intended regex is more like:
(?:\b|_)[Tt]est
A side note. The intention appears to be to find instances of 'test' set off as a separate 'word', so that you
don't see patterns like 'latest'. However, the pattern matches 'testify' and probably shouldn't. It does not
match myUnitTest, and probably should. It's perhaps not a great idea to fix this, for backwards-
compatibilty reasons. OTOH, it is 0.11, so....
Google Code Info:
Issue #: 335
Author: jlundell
Created On: 2010-04-30T21:12:31.000Z
Closed On:
The text was updated successfully, but these errors were encountered: