~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Aaron Bentley
  • Date: 2012-01-16 16:42:59 UTC
  • mto: (6.1.30 trunk)
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: aaron@canonical.com-20120116164259-qcx32bgzhabmopnc
Cleaner logging switch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
 
114
114
class ForkedFake:
115
115
 
116
 
    def __init__(self, port, messages=None):
 
116
    def __init__(self, port, messages=None, write_logs=False):
117
117
        self.pid = None
118
118
        self.port = port
119
119
        if messages is None:
121
121
        else:
122
122
            self.messages = messages
123
123
        self.read_end, self.write_end = os.pipe()
 
124
        self.write_logs = write_logs
124
125
 
125
126
    @staticmethod
126
127
    def from_client(client, messages=None):
144
145
            for message in messages:
145
146
                message.setdefault('headers', {})
146
147
        self.is_ready()
147
 
#        logging.basicConfig(
148
 
#            stream=sys.stderr, level=logging.INFO)
 
148
        if self.write_logs:
 
149
            logging.basicConfig(
 
150
                stream=sys.stderr, level=logging.INFO)
149
151
        service.serve_forever()
150
152
 
151
153
    def __exit__(self, exc_type, exc_val, traceback):