summaryrefslogtreecommitdiff
path: root/test/base
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-04-24 06:23:19 -0600
committerGord Thompson <gord@gordthompson.com>2020-05-01 12:12:57 -0600
commit7baf42883f177a6f666a1cb550f4357aa7606a25 (patch)
treec2a24f9bbc9608939d754a7eb9c3d1598fef660c /test/base
parent31898e90618e946aca3eef2914b03e8534c464aa (diff)
downloadsqlalchemy-7baf42883f177a6f666a1cb550f4357aa7606a25.tar.gz
Add warn_deprecated_limited feature
Fixes: #5268 Change-Id: I2f976048af4f8d6dd03a14efa31d179bd7324ba6
Diffstat (limited to 'test/base')
-rw-r--r--test/base/test_warnings.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/base/test_warnings.py b/test/base/test_warnings.py
new file mode 100644
index 000000000..c8807df09
--- /dev/null
+++ b/test/base/test_warnings.py
@@ -0,0 +1,36 @@
+from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_deprecated
+from sqlalchemy.testing import fixtures
+from sqlalchemy.util.deprecations import warn_deprecated_limited
+from sqlalchemy.util.langhelpers import _hash_limit_string
+
+
+class WarnDeprecatedLimitedTest(fixtures.TestBase):
+ __backend__ = False
+
+ def test_warn_deprecated_limited_text(self):
+ with expect_deprecated("foo has been deprecated"):
+ warn_deprecated_limited(
+ "%s has been deprecated [%d]", ("foo", 1), "1.3"
+ )
+
+ def test_warn_deprecated_limited_cap(self):
+ """ warn_deprecated_limited() and warn_limited() use
+ _hash_limit_string
+
+ actually just verifying that _hash_limit_string works as expected
+ """
+ occurrences = 100
+ cap = 10
+
+ printouts = set()
+ messages = set()
+ for i in range(occurrences):
+ message = _hash_limit_string(
+ "this is a unique message: %d", cap, (i,)
+ )
+ printouts.add(str(message))
+ messages.add(message)
+
+ eq_(len(printouts), occurrences)
+ eq_(len(messages), cap)