[autotest] Use a deprecation wrapper for find_possible_tests

The default behavior for warnings is to print a message (like
logging).  This can be configured at runtime to raise an exception (or
silence entirely), so it can be useful if we want to remove deprecated
calls during a fixit.


Change-Id: I2d2cd3a475fdc6f4a416ad17d00abd12df2d7a5f
Reviewed-on: https://chromium-review.googlesource.com/448032
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/server/cros/dynamic_suite/suite.py b/server/cros/dynamic_suite/suite.py
index bda3608..9aff102 100644
--- a/server/cros/dynamic_suite/suite.py
+++ b/server/cros/dynamic_suite/suite.py
@@ -4,12 +4,14 @@
 import datetime
 import difflib
+import functools
 import hashlib
 import logging
 import operator
 import os
 import re
 import sys
+import warnings
 import common
@@ -654,6 +656,19 @@
+def _deprecated_suite_method(func):
+    """Decorator for deprecated Suite static methods.
+    TODO(ayatane): This is used to decorate functions that are called as
+    static methods on Suite.
+    """
+    @functools.wraps(func)
+    def wrapper(*args, **kwargs):
+        warnings.warn('Calling this method from Suite is deprecated')
+        return func(*args, **kwargs)
+    return staticmethod(wrapper)
 class Suite(object):
     A suite of tests, defined by some predicate over control file variables.
@@ -1531,7 +1546,7 @@
     # TODO(ayatane): These methods are kept on the Suite class for
     # backward compatibility.
-    find_possible_tests = staticmethod(find_possible_tests)
+    find_possible_tests = _deprecated_suite_method(find_possible_tests)
 def _is_nonexistent_board_error(e):