Load response.content in browser (for debugging)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def dump_response_on_file(response, filepath=None):
    """Useful when debugging responses. Calls to this method should not be
    committed."""
    if not filepath:
        from tempfile import mkstemp
        _, filepath = mkstemp(text=True)
    f = file(filepath, 'w')
    f.write(response.content)
    f.close()
    return filepath

def load_response_on_firefox(response):
    """ load html of a response for debugging purposes
    Attention: Calls to this method should not be
    committed.
    """
    import subprocess
    fpath = dump_response_on_file(response)
    subprocess.call(['firefox', fpath])

More like this

  1. View response's content in a browser while testing by ryankask1 3 years, 3 months ago
  2. A smart trace() command by aparajita 4 years, 10 months ago
  3. Template context debugger with (I)Pdb by denis 4 years, 10 months ago
  4. CSV to JSON Fixture by briangershon 4 years, 8 months ago
  5. Simple Exception Response for AJAX debugging by newmaniese 6 years, 1 month ago

Comments

(Forgotten your password?)