jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] tests: Generic deprecation assertion
......................................................................
[FEAT] tests: Generic deprecation assertion
Instead of requiring the exact deprecation message it is just generally
asserting there are deprecation messages.
Change-Id: I428084f5d05ce7a928a3cad61e8ee182fece0a4b
---
M tests/aspects.py
M tests/site_tests.py
2 files changed, 10 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 44e2653..446fe6f 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -32,6 +32,7 @@
import inspect
import itertools
import os
+import re
import sys
import time
import warnings
@@ -1230,6 +1231,8 @@
"""Test cases for deprecation function in the tools module."""
+ _generic_match = re.compile(r'.* is deprecated(, use .* instead)?\.')
+
def __init__(self, *args, **kwargs):
super(DeprecationTestCase, self).__init__(*args, **kwargs)
self.warning_log = []
@@ -1251,8 +1254,12 @@
messages = [str(item.message) for item in self.warning_log]
return messages
- def assertDeprecation(self, msg):
- self.assertIn(msg, self.deprecation_messages)
+ def assertDeprecation(self, msg=None):
+ if msg is None:
+ self.assertGreater(sum(1 for msg in self.deprecation_messages
+ if self._generic_match.match(msg)), 0)
+ else:
+ self.assertIn(msg, self.deprecation_messages)
if self._do_test_warning_filename:
self.assertDeprecationFile(self.expect_warning_filename)
diff --git a/tests/site_tests.py b/tests/site_tests.py
index ba372f7..e6e8bb5 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -55,6 +55,7 @@
self.assertIsInstance(ver, tuple)
self.assertTrue(all(isinstance(ver[i], int) for i in (0, 1)))
self.assertIsInstance(ver[2], basestring)
+ self.assertDeprecation()
def test_token(self):
"""Test ability to get page tokens."""
--
To view, visit https://gerrit.wikimedia.org/r/218005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I428084f5d05ce7a928a3cad61e8ee182fece0a4b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits