Skip to content

Conversation

@gabrielfalcao
Copy link
Owner

@gabrielfalcao gabrielfalcao commented May 12, 2021

This PR contains a proposed solution for #388

Main Changes

new properties added to HTTPrettyRequest

  • request.path - string
  • request.url - string
  • request.host - string
  • request.method - string
  • request.protocol - string

Display URL and other HTTP request metadata in UnmockedError whenever possible

log every http request that was captured

  1. Can be enabled by setting log level in the httpretty.core logger
import logging
from httpretty.core import logger
logger.setLevel(logging.DEBUG)
logging.getLogger("httpretty.core").setLevel(logging.DEBUG)
  1. Can ne enabled via the new verbose boolean argument of API triggers and decorators
import httpretty

httpretty.enabled(verbose=True)

@httpretty.httprettified(verbose=True)
def test_my_test():
    pass # your test

@httpretty.activate(verbose=True)
def test_is_active():
    pass # your test

@httpretty.activate(verbose=True)
httpretty.enable(verbose.True)
etc.

Another option is to set the logger level manually

import logging

from httpretty.core import logger

logger.setLevel(logging.DEBUG)
@gabrielfalcao gabrielfalcao self-assigned this May 12, 2021
Copy link

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That solves my use case 👌

@gabrielfalcao
Copy link
Owner Author

@sauloperez I'm happy to hear that. I'll just add some more tests and documentation and should make a new minor release today or tomorrow.

@sauloperez
Copy link

sauloperez commented May 12, 2021 via email

@gabrielfalcao gabrielfalcao merged commit b6161ce into master May 13, 2021
TheRealFalcon added a commit to TheRealFalcon/cloud-init that referenced this pull request May 13, 2021
Httpretty now logs all requests by default which gets mixed up with our
logging tests. Also we were incorrectly setting a logging level to
'None', which now also causes issues with the new httpretty version.
See gabrielfalcao/HTTPretty#419
OddBloke pushed a commit to canonical/cloud-init that referenced this pull request May 14, 2021
httpretty now logs all requests by default which gets mixed up with our
logging tests. Also we were incorrectly setting a logging level to
'None', which now also causes issues with the new httpretty version.
See gabrielfalcao/HTTPretty#419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants