Skip to content

Commit

Permalink
Cleanup JSONEncoder.encode
Browse files Browse the repository at this point in the history
  • Loading branch information
fahhem committed Feb 9, 2016
1 parent df39239 commit 5012fc1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions openhtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import inspect
import itertools
import json
import logging
import os
import signal
import socket
import sys
from json import JSONEncoder

import gflags
import mutablerecords
Expand All @@ -47,7 +47,7 @@ class InvalidTestPhaseError(Exception):
"""Raised when an invalid method is decorated."""


class OutputToJSON(JSONEncoder):
class OutputToJSON(json.JSONEncoder):
"""Return an output callback that writes JSON Test Records.
An example filename_pattern might be:
Expand Down
2 changes: 1 addition & 1 deletion openhtf/exe/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, config, test, plugs, dut_id):

def AsJSON(self):
"""Return JSON representation of the test's serialized state."""
return json.JSONEncoder().encode(util.convert_to_dict(self))
return json.dumps(util.convert_to_dict(self))

def _asdict(self):
"""Return a dict representation of the test's state."""
Expand Down
2 changes: 1 addition & 1 deletion openhtf/io/frontend/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_prompt(name):
@app.route('/station/<name>/prompt/<id>/', methods=['POST'])
def prompt(name, id):
"""Handle requests that respond to prompts."""
msg = json.JSONEncoder().encode({'id': id, 'response': flask.request.data})
msg = json.dumps({'id': id, 'response': flask.request.data})
query_framework(name, method='POST', message=msg)
return 'OK'

Expand Down
2 changes: 1 addition & 1 deletion openhtf/io/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def do_GET(self): # pylint: disable=invalid-name
prompt = user_input.get_prompt_manager().prompt
if prompt:
result['prompt'] = util.convert_to_dict(prompt)
self.wfile.write(json.JSONEncoder().encode(result))
self.wfile.write(json.dumps(result))

def do_POST(self): # pylint: disable=invalid-name
"""Parse a prompt response and send it to the PromptManager."""
Expand Down

0 comments on commit 5012fc1

Please sign in to comment.