Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Evan Edmond
fslpy
Commits
f3fd6d0e
Commit
f3fd6d0e
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Don't hard code line numbers
parent
3bf3e154
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_deprecated.py
+17
-7
17 additions, 7 deletions
tests/test_deprecated.py
with
17 additions
and
7 deletions
tests/test_deprecated.py
+
17
−
7
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment