Skip to content

Commit 0173443

Browse files
authored
Merge pull request #71 from casework/fix_deprecation_warning_style
Use Warning classes not ignored by default filters
2 parents 9b78310 + a0b2d1e commit 0173443

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

case_utils/local_uuid.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def configure() -> None:
3838
if os.getenv("DEMO_UUID_REQUESTING_NONRANDOM") == "NONRANDOM_REQUESTED":
3939
warnings.warn(
4040
"Environment variable DEMO_UUID_REQUESTING_NONRANDOM is deprecated. See case_utils.local_uuid.demo_uuid for usage notes on its replacement, CASE_DEMO_NONRANDOM_UUID_BASE. Proceeding with random UUIDs.",
41-
DeprecationWarning,
41+
FutureWarning,
4242
)
4343
return
4444

@@ -49,12 +49,14 @@ def configure() -> None:
4949
base_dir_original_path = pathlib.Path(env_base_dir_name)
5050
if not base_dir_original_path.exists():
5151
warnings.warn(
52-
"Environment variable CASE_DEMO_NONRANDOM_UUID_BASE is expected to refer to an existing directory. Proceeding with random UUIDs."
52+
"Environment variable CASE_DEMO_NONRANDOM_UUID_BASE is expected to refer to an existing directory. Proceeding with random UUIDs.",
53+
RuntimeWarning,
5354
)
5455
return
5556
if not base_dir_original_path.is_dir():
5657
warnings.warn(
57-
"Environment variable CASE_DEMO_NONRANDOM_UUID_BASE is expected to refer to a directory. Proceeding with random UUIDs."
58+
"Environment variable CASE_DEMO_NONRANDOM_UUID_BASE is expected to refer to a directory. Proceeding with random UUIDs.",
59+
RuntimeWarning,
5860
)
5961
return
6062

@@ -108,9 +110,9 @@ def demo_uuid() -> str:
108110
"""
109111
This function generates a repeatable UUID, drawing on non-varying elements of the environment and process call for entropy.
110112
111-
WARNING: This function was developed for use ONLY for reducing (but not eliminating) version-control edits to identifiers in sample data. It creates UUIDs that are decidedly NOT random, and should remain consistent on repeated calls to the importing script.
113+
WARNING: This function was developed for use ONLY for reducing (but not eliminating) version-control edits to identifiers when generating sample data. It creates UUIDs that are decidedly NOT random, and should remain consistent on repeated calls to the importing script.
112114
113-
To prevent accidental non-random UUID usage, an environment variable must be set to a string provided by the caller. The variable's required value is the path to some directory. The variable's recommended value is the equivalent of the Make variable "top_srcdir" - that is, the root directory of the containing Git repository, some parent of the current process's current working directory.
115+
To prevent accidental non-random UUID usage, an environment variable, CASE_DEMO_NONRANDOM_UUID_BASE, must be set to a string provided by the caller. The variable's required value is the path to some directory. The variable's recommended value is the equivalent of the Make variable "top_srcdir" - that is, the root directory of the containing Git repository, some parent of the current process's current working directory.
114116
"""
115117
global DEMO_UUID_BASE
116118
global DEMO_UUID_COUNTER

tests/case_utils/test_local_uuid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
def test_local_uuid_deprecation(monkeypatch: pytest.MonkeyPatch) -> None:
2020
monkeypatch.setenv("DEMO_UUID_REQUESTING_NONRANDOM", "NONRANDOM_REQUESTED")
21-
with pytest.warns(DeprecationWarning):
21+
with pytest.warns(FutureWarning):
2222
case_utils.local_uuid.configure()
2323

2424

2525
def test_local_uuid_nondirectory(monkeypatch: pytest.MonkeyPatch) -> None:
2626
monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/null")
27-
with pytest.warns(UserWarning):
27+
with pytest.warns(RuntimeWarning):
2828
case_utils.local_uuid.configure()
2929

3030

3131
def test_local_uuid_nonexistent(monkeypatch: pytest.MonkeyPatch) -> None:
3232
monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/nonexistent")
33-
with pytest.warns(UserWarning):
33+
with pytest.warns(RuntimeWarning):
3434
case_utils.local_uuid.configure()

0 commit comments

Comments
 (0)