Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/citrine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
https://citrineinformatics.github.io/citrine-python/index.html
"""
import warnings

from citrine.citrine import Citrine # noqa: F401
from .__version__ import __version__ # noqa: F401

# Python's default warning filter hides DeprecationWarning unless triggered from
# __main__ (PEP 565). Surface DeprecationWarnings raised from citrine.* so users
# see them before the deprecated APIs are removed.
warnings.filterwarnings("default", category=DeprecationWarning, module=r"citrine(\.|$)")
2 changes: 1 addition & 1 deletion src/citrine/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.0.3"
__version__ = "4.0.4"
19 changes: 19 additions & 0 deletions tests/test_citrine.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import platform
import warnings
from datetime import datetime, timezone

import jwt
import pytest
import requests_mock

from citrine import Citrine
from citrine._utils.functions import migrate_deprecated_argument


def refresh_token(expiration: datetime = None) -> dict:
Expand Down Expand Up @@ -103,3 +105,20 @@ def test_citrine_user_agent():
# enforce them to be ints. It's common to see strings used
# as the patch version
assert len(product_version.split('.')) == 3


def test_citrine_deprecation_warnings_visible_by_default():
import importlib

import citrine
Comment on lines +111 to +113
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imports should be up with the others.


with warnings.catch_warnings(record=True) as caught:
warnings.resetwarnings()
# Mirror Python's default filter: DeprecationWarning hidden outside __main__.
warnings.simplefilter("ignore", category=DeprecationWarning)
importlib.reload(citrine)

migrate_deprecated_argument(None, "new", "value", "old")

deprecations = [w for w in caught if issubclass(w.category, DeprecationWarning)]
assert any("'old' is deprecated" in str(w.message) for w in deprecations)
Loading