Skip to content

Commit 7c8f005

Browse files
committed
Merge pull request nose-devs#950 from kengruven/master
Fix NOSE_TESTMATCH default regex.
2 parents 9371c97 + dd93fe0 commit 7c8f005

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

README.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ nose collects tests automatically from python source files,
5151
directories and packages found in its working directory (which
5252
defaults to the current working directory). Any python source file,
5353
directory or package that matches the testMatch regular expression (by
54-
default: *(?:^|[b_.-])[Tt]est)* will be collected as a test (or source
55-
for collection of tests). In addition, all other packages found in the
54+
default: *(?:\b|_)[Tt]est* will be collected as a test (or source for
55+
collection of tests). In addition, all other packages found in the
5656
working directory will be examined for python source files or
5757
directories that match testMatch. Package discovery descends all the
5858
way down the tree, so package.tests and package.sub.tests and
@@ -216,8 +216,8 @@ Options
216216
-m=REGEX, --match=REGEX, --testmatch=REGEX
217217

218218
Files, directories, function names, and class names that match this
219-
regular expression are considered tests. Default:
220-
(?:^|[b_./-])[Tt]est [NOSE_TESTMATCH]
219+
regular expression are considered tests. Default: (?:\b|_)[Tt]est
220+
[NOSE_TESTMATCH]
221221

222222
--tests=NAMES
223223

nose/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Config(object):
147147
148148
self.env = env = kw.pop('env', {})
149149
self.args = ()
150-
self.testMatch = re.compile(r'(?:^|[\\b_\\.%s-])[Tt]est' % os.sep)
150+
self.testMatch = re.compile(env.get('NOSE_TESTMATCH', r'(?:\b|_)[Tt]est'))
151151
self.addPaths = not env.get('NOSE_NOPATH', False)
152152
self.configSection = 'nosetests'
153153
self.debug = env.get('NOSE_DEBUG')
@@ -180,8 +180,7 @@ class Config(object):
180180
def __init__(self, **kw):
181181
self.env = env = kw.pop('env', {})
182182
self.args = ()
183-
self.testMatchPat = env.get('NOSE_TESTMATCH',
184-
r'(?:^|[\b_\.%s-])[Tt]est' % os.sep)
183+
self.testMatchPat = env.get('NOSE_TESTMATCH', r'(?:\b|_)[Tt]est')
185184
self.testMatch = re.compile(self.testMatchPat)
186185
self.addPaths = not env.get('NOSE_NOPATH', False)
187186
self.configSection = 'nosetests'

nose/sphinx/pluginopts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def format_help(self):
157157
return self.doc.replace('%prog', self.prog).replace(':\n', '::\n')
158158

159159
def add_option(self, *arg, **kw):
160+
for k, v in kw.items():
161+
if isinstance(v, str):
162+
kw[k] = v.replace('\\', '\\\\')
160163
self.opts.append(Opt(*arg, **kw))
161164

162165

nose/usage.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ nose collects tests automatically from python source files,
22
directories and packages found in its working directory (which
33
defaults to the current working directory). Any python source file,
44
directory or package that matches the testMatch regular expression
5-
(by default: `(?:^|[\b_\.-])[Tt]est)` will be collected as a test (or
5+
(by default: `(?:\\b|_)[Tt]est` will be collected as a test (or
66
source for collection of tests). In addition, all other packages
77
found in the working directory will be examined for python source files
88
or directories that match testMatch. Package discovery descends all

nosetests.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH "NOSETESTS" "1" "April 04, 2015" "1.3" "nose"
3+
.TH "NOSETESTS" "1" "November 11, 2015" "1.3" "nose"
44
.SH NAME
55
nosetests \- Nicer testing for Python
66
.
@@ -43,7 +43,7 @@ nose collects tests automatically from python source files,
4343
directories and packages found in its working directory (which
4444
defaults to the current working directory). Any python source file,
4545
directory or package that matches the testMatch regular expression
46-
(by default: \fI(?:^|[b_.\-])[Tt]est)\fP will be collected as a test (or
46+
(by default: \fI(?:\eb|_)[Tt]est\fP will be collected as a test (or
4747
source for collection of tests). In addition, all other packages
4848
found in the working directory will be examined for python source files
4949
or directories that match testMatch. Package discovery descends all
@@ -236,7 +236,7 @@ Look for tests in this directory under Python 3.x. Functions the same as \(aqwhe
236236
.INDENT 0.0
237237
.TP
238238
.B \-m=REGEX, \-\-match=REGEX, \-\-testmatch=REGEX
239-
Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:^|[b_./\-])[Tt]est [NOSE_TESTMATCH]
239+
Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:\eb|_)[Tt]est [NOSE_TESTMATCH]
240240
.UNINDENT
241241
.INDENT 0.0
242242
.TP

0 commit comments

Comments
 (0)