Skip to content

Commit 3efb3f1

Browse files
authored
Merge pull request #610 from python-cmd2/pytestupdates
Fix pytest deprecation warnings
2 parents 64119e2 + 93accd4 commit 3efb3f1

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cmd2.egg-info
1212
# Code Coverage
1313
.coverage
1414
htmlcov
15+
junit
1516

1617
# PyCharm
1718
.idea

tests/test_bashcompletion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def my_fdopen(fd, mode, *args):
124124

125125
# noinspection PyShadowingNames
126126
@pytest.mark.skipif(skip_no_argcomplete or skip_windows, reason=skip_reason)
127-
def test_invalid_ifs(parser1, mock):
127+
def test_invalid_ifs(parser1, mocker):
128128
completer = CompletionFinder()
129129

130-
mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1',
130+
mocker.patch.dict(os.environ, {'_ARGCOMPLETE': '1',
131131
'_ARGCOMPLETE_IFS': '\013\013'})
132132

133-
mock.patch.object(os, 'fdopen', my_fdopen)
133+
mocker.patch.object(os, 'fdopen', my_fdopen)
134134

135135
with pytest.raises(SystemExit):
136136
completer(parser1, AutoCompleter(parser1), exit_method=sys.exit)
@@ -178,16 +178,16 @@ def fdopen_fail_8(fd, mode, *args):
178178

179179
# noinspection PyShadowingNames
180180
@pytest.mark.skipif(skip_no_argcomplete or skip_windows, reason=skip_reason)
181-
def test_fail_alt_stdout(parser1, mock):
181+
def test_fail_alt_stdout(parser1, mocker):
182182
completer = CompletionFinder()
183183

184184
comp_line = 'media movies list '
185-
mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1',
185+
mocker.patch.dict(os.environ, {'_ARGCOMPLETE': '1',
186186
'_ARGCOMPLETE_IFS': '\013',
187187
'COMP_TYPE': '63',
188188
'COMP_LINE': comp_line,
189189
'COMP_POINT': str(len(comp_line))})
190-
mock.patch.object(os, 'fdopen', fdopen_fail_8)
190+
mocker.patch.object(os, 'fdopen', fdopen_fail_8)
191191

192192
try:
193193
choices = {'actor': query_actors, # function

tests/test_transcript.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ def test_history_transcript_bad_filename(request, capsys):
200200
( '/tmp is nice', re.escape('/tmp is nice') ),
201201
( 'slash at end/', re.escape('slash at end/') ),
202202
# escaped slashes
203-
( 'not this slash\/ or this one\/', re.escape('not this slash/ or this one/' ) ),
203+
( r'not this slash\/ or this one\/', re.escape('not this slash/ or this one/' ) ),
204204
# regexes
205205
( '/.*/', '.*' ),
206206
( 'specials ^ and + /[0-9]+/', re.escape('specials ^ and + ') + '[0-9]+' ),
207-
( '/a{6}/ but not \/a{6} with /.*?/ more', 'a{6}' + re.escape(' but not /a{6} with ') + '.*?' + re.escape(' more') ),
208-
( 'not \/, use /\|?/, not \/', re.escape('not /, use ') + '\|?' + re.escape(', not /') ),
207+
( r'/a{6}/ but not \/a{6} with /.*?/ more', 'a{6}' + re.escape(' but not /a{6} with ') + '.*?' + re.escape(' more') ),
208+
( r'not \/, use /\|?/, not \/', re.escape('not /, use ') + r'\|?' + re.escape(', not /') ),
209209
# inception: slashes in our regex. backslashed on input, bare on output
210-
( 'not \/, use /\/?/, not \/', re.escape('not /, use ') + '/?' + re.escape(', not /') ),
211-
( 'lots /\/?/ more /.*/ stuff', re.escape('lots ') + '/?' + re.escape(' more ') + '.*' + re.escape(' stuff') ),
210+
( r'not \/, use /\/?/, not \/', re.escape('not /, use ') + '/?' + re.escape(', not /') ),
211+
( r'lots /\/?/ more /.*/ stuff', re.escape('lots ') + '/?' + re.escape(' more ') + '.*' + re.escape(' stuff') ),
212212
])
213213
def test_parse_transcript_expected(expected, transformed):
214214
app = CmdLineApp()

0 commit comments

Comments
 (0)