FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
diffpy.utils/tests/test_deprecator.py at main · diffpy/diffpy.utils · GitHub
diffpy
diffpy.utils
Repository navigation
Code
Issues
23
(23)
Pull requests
3
(3)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
diffpy.utils
/
tests
/
test_deprecator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (28 loc) · 1.02 KB
Breadcrumbs
diffpy.utils
/
tests
/
test_deprecator.py
Copy path
File metadata and controls
38 lines (28 loc) · 1.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import
pytest
from
diffpy
.
utils
.
_deprecator
import
build_deprecation_message
,
deprecated
old_base
=
"diffpy.utils"
old_name
=
"oldFunction"
new_name
=
"new_function"
removal_version
=
"4.0.0"
dep_msg
=
build_deprecation_message
(
old_base
,
old_name
,
new_name
,
removal_version
)
@
deprecated
(
dep_msg
)
def
oldFunction
(
print_msg
):
"""This function is deprecated and will be removed in version 4.0.0.
Please use newFunction instead
"""
return
new_function
(
print_msg
)
def
new_function
(
print_msg
):
print
(
print_msg
)
return
def
test_deprecated
(
capsys
):
# Case: user deprecates a function with the deprecated decorator
# Expected: DeprecationWarning is raised when the function is called
# and the function executes correctly
expected_print_msg
=
"Testing deprecated function"
with
pytest
.
deprecated_call
(
match
=
dep_msg
):
oldFunction
(
expected_print_msg
)
captured
=
capsys
.
readouterr
()
actual_print_msg
=
captured
.
out
.
strip
()
assert
actual_print_msg
==
expected_print_msg
Back
|
FazBrowse Home
|
New Git URL