Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslpy
Commits
f3fd6d0e
Commit
f3fd6d0e
authored
Sep 05, 2019
by
Paul McCarthy
🚵
Browse files
TEST: Don't hard code line numbers
parent
3bf3e154
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_deprecated.py
View file @
f3fd6d0e
...
...
@@ -7,12 +7,22 @@ import pytest
import
fsl.utils.deprecated
as
deprecated
# the line number of the warning is hard coded in
# the unit tests below. Don't change the line number!
# these get updated in the relevant functions
WARNING_LINE_NUMBER
=
None
DEPRECATED_LINE_NUMBER
=
None
def
_linenum
(
pattern
):
with
open
(
__file__
,
'rt'
)
as
f
:
for
i
,
line
in
enumerate
(
f
.
readlines
(),
1
):
if
pattern
in
line
:
return
i
return
-
1
def
emit_warning
():
deprecated
.
warn
(
'blag'
,
vin
=
'1.0.0'
,
rin
=
'2.0.0'
,
msg
=
'yo'
)
WARNING_LINE_NUMBER
=
13
global
WARNING_LINE_NUMBER
WARNING_LINE_NUMBER
=
_linenum
(
'deprecated.warn(
\'
blag
\'
'
)
@
deprecated
.
deprecated
(
vin
=
'1.0.0'
,
rin
=
'2.0.0'
,
msg
=
'yo'
)
...
...
@@ -20,9 +30,9 @@ def depfunc():
pass
def
call_dep_func
():
depfunc
()
DEPRECATED_LINE_NUMBER
=
23
depfunc
()
# mark
global
DEPRECATED_LINE_NUMBER
DEPRECATED_LINE_NUMBER
=
_linenum
(
'depfunc() # mark'
)
def
_check_warning
(
w
,
name
,
lineno
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment