# Path: emit/messages.py
# class Message(object):
#     'Convenient wrapper around a dictionary to provide attribute access'
#     def __init__(self, *args, **kwargs):
#         self.bundle = dict(*args, **kwargs)
# 
#     def __getattr__(self, attr):
#         try:
#             return self.bundle[attr]
#         except KeyError:
#             raise AttributeError(
#                 '"%s" is not included in this message' % attr
#             )
# 
#     def __dir__(self):
#         'get directory of attributes. include bundle.'
#         return sorted(list(['bundle'] + list(self.bundle.keys())))
# 
#     def __repr__(self):
#         'representation of this message'
#         return 'Message(%s)' % (
#             ', '.join('%s=%s' % pair for pair in self.bundle.items())
#         )
# 
#     def __eq__(self, other):
#         'test equality of two messages'
#         return self.bundle == other.bundle
# 
#     def as_dict(self):
#         '''\
#         representation of this message as a dictionary
# 
#         :returns: dict
#         '''
#         return self.bundle
# 
#     def as_json(self):
#         '''
#         representation of this message as a json object
# 
#         :returns: str
#         '''
#         return json.dumps(self.as_dict())


import json
from unittest import TestCase
from emit.messages import Message
'tests for message'



class MessageTests(TestCase):
    'tests for Message'
    def test_dot_access(self):
        'accessing attributes'
        x = Message(x=1)
        self.assertEqual(1, x.x)

    def test_access_missing(self):
        'accessing attributes that do not exist'
        x = Message(x=1)
        try:
            self.assertRaisesRegex(
                AttributeError, '"y" is not included in this message',
                getattr, x, 'y'
            )
        except AttributeError:  # python 2.6
            self.assertRaises(
                AttributeError,
                getattr, x, 'y'
            )

    def test_repr(self):

# Path: emit/messages.py
# class Message(object):
#     'Convenient wrapper around a dictionary to provide attribute access'
#     def __init__(self, *args, **kwargs):
#         self.bundle = dict(*args, **kwargs)
# 
#     def __getattr__(self, attr):
#         try:
#             return self.bundle[attr]
#         except KeyError:
#             raise AttributeError(
#                 '"%s" is not included in this message' % attr
#             )
# 
#     def __dir__(self):
#         'get directory of attributes. include bundle.'
#         return sorted(list(['bundle'] + list(self.bundle.keys())))
# 
#     def __repr__(self):
#         'representation of this message'
#         return 'Message(%s)' % (
#             ', '.join('%s=%s' % pair for pair in self.bundle.items())
#         )
# 
#     def __eq__(self, other):
#         'test equality of two messages'
#         return self.bundle == other.bundle
# 
#     def as_dict(self):
#         '''\
#         representation of this message as a dictionary
# 
#         :returns: dict
#         '''
#         return self.bundle
# 
#     def as_json(self):
#         '''
#         representation of this message as a json object
# 
#         :returns: str
#         '''
#         return json.dumps(self.as_dict())


# Path: tests/message_tests.py
import json
from unittest import TestCase
from emit.messages import Message

'tests for message'



class MessageTests(TestCase):
    'tests for Message'
    def test_dot_access(self):
        'accessing attributes'
        x = Message(x=1)
        self.assertEqual(1, x.x)

    def test_access_missing(self):
        'accessing attributes that do not exist'
        x = Message(x=1)
        try:
            self.assertRaisesRegex(
                AttributeError, '"y" is not included in this message',
                getattr, x, 'y'
            )
        except AttributeError:  # python 2.6
            self.assertRaises(
                AttributeError,
                getattr, x, 'y'
            )

    def test_repr(self):

        x = Message(x=1, y=2)