brain_responses.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. """
  2. Astroid hooks for responses.
  3. It might need to be manually updated from the public methods of
  4. :class:`responses.RequestsMock`.
  5. See: https://github.com/getsentry/responses/blob/master/responses.py
  6. """
  7. from astroid.brain.helpers import register_module_extender
  8. from astroid.builder import parse
  9. from astroid.manager import AstroidManager
  10. def responses_funcs():
  11. return parse(
  12. """
  13. DELETE = "DELETE"
  14. GET = "GET"
  15. HEAD = "HEAD"
  16. OPTIONS = "OPTIONS"
  17. PATCH = "PATCH"
  18. POST = "POST"
  19. PUT = "PUT"
  20. response_callback = None
  21. def reset():
  22. return
  23. def add(
  24. method=None, # method or ``Response``
  25. url=None,
  26. body="",
  27. adding_headers=None,
  28. *args,
  29. **kwargs
  30. ):
  31. return
  32. def add_passthru(prefix):
  33. return
  34. def remove(method_or_response=None, url=None):
  35. return
  36. def replace(method_or_response=None, url=None, body="", *args, **kwargs):
  37. return
  38. def add_callback(
  39. method, url, callback, match_querystring=False, content_type="text/plain"
  40. ):
  41. return
  42. calls = []
  43. def __enter__():
  44. return
  45. def __exit__(type, value, traceback):
  46. success = type is None
  47. return success
  48. def activate(func):
  49. return func
  50. def start():
  51. return
  52. def stop(allow_assert=True):
  53. return
  54. """
  55. )
  56. register_module_extender(AstroidManager(), "responses", responses_funcs)