__init__.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # <HTTPretty - HTTP client mock for Python>
  4. # Copyright (C) <2011-2018> Gabriel Falcao <gabriel@nacaolivre.org>
  5. #
  6. # Permission is hereby granted, free of charge, to any person
  7. # obtaining a copy of this software and associated documentation
  8. # files (the "Software"), to deal in the Software without
  9. # restriction, including without limitation the rights to use,
  10. # copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the
  12. # Software is furnished to do so, subject to the following
  13. # conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be
  16. # included in all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  20. # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  25. # OTHER DEALINGS IN THE SOFTWARE.
  26. # flake8: noqa
  27. from . import core
  28. from .errors import HTTPrettyError, UnmockedError
  29. from .version import version
  30. __version__ = version
  31. # aliases
  32. EmptyRequestHeaders = core.EmptyRequestHeaders
  33. Entry = core.Entry
  34. HTTPrettyRequestEmpty = core.HTTPrettyRequestEmpty
  35. URIInfo = core.URIInfo
  36. URIMatcher = core.URIMatcher
  37. httprettified = core.httprettified
  38. httprettized = core.httprettized
  39. httpretty = core.httpretty
  40. HTTPretty = httpretty
  41. activate = httprettified
  42. enabled = httprettized
  43. enable = httpretty.enable
  44. register_uri = httpretty.register_uri
  45. disable = httpretty.disable
  46. is_enabled = httpretty.is_enabled
  47. reset = httpretty.reset
  48. Response = httpretty.Response
  49. GET = httpretty.GET
  50. PUT = httpretty.PUT
  51. POST = httpretty.POST
  52. DELETE = httpretty.DELETE
  53. HEAD = httpretty.HEAD
  54. PATCH = httpretty.PATCH
  55. OPTIONS = httpretty.OPTIONS
  56. CONNECT = httpretty.CONNECT
  57. def last_request():
  58. """
  59. :returns: the last :py:class:`~httpretty.core.HTTPrettyRequest`
  60. """
  61. return httpretty.last_request
  62. def has_request():
  63. """
  64. :returns: bool - whether any request has been made
  65. """
  66. return not isinstance(httpretty.last_request.headers, EmptyRequestHeaders)