Skip to content

Commit 18462e5

Browse files
authored
Merge pull request #1600 from danforthcenter/add-verbose-warn
Update warn to utilize the verbose global parameter
2 parents 1429294 + 6692372 commit 18462e5

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

plantcv/plantcv/warn.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Warnings handling
22

33
import sys
4+
from plantcv.plantcv import params
45

56

67
def warn(warning):
7-
"""Print out warning message
8+
"""Print a warning message to stderr.
89
9-
Inputs:
10-
warning = warning message text
10+
Parameters
11+
----------
12+
warning : str
13+
Warning message to print.
1114
12-
:param warning: str
15+
Returns
16+
-------
17+
None
18+
Function does not return anything.
1319
"""
14-
print(f"Warning: {warning}", file=sys.stderr)
20+
if params.verbose:
21+
print(f"Warning: {warning}", file=sys.stderr)

tests/plantcv/test_warn.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from plantcv.plantcv import warn
2+
3+
4+
def test_warn():
5+
"""Test for PlantCV."""
6+
warn("This is a warning message.")
7+
assert True

0 commit comments

Comments
 (0)