jamesls/fakeredis

Bug - FakeConnection has no attribute host

victorct-pronto opened this issue · 2 comments

Everything on the library is working fine, except when you print the instance it gives the following error:

In [15]: _conn = fakeredis.FakeStrictRedis()

In [16]: _conn
Out[16]: ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

/usr/local/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    397                         if cls is not object \
    398                                 and callable(cls.__dict__.get('__repr__')):
--> 399                             return _repr_pprint(obj, self, cycle)
    400
    401             return _default_pprint(obj, self, cycle)

/usr/local/lib/python3.7/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    687     """A pprint that just redirects to the normal repr function."""
    688     # Find newlines and replace them with p.break_()
--> 689     output = repr(obj)
    690     for idx,output_line in enumerate(output.splitlines()):
    691         if idx:

/usr/local/lib/python3.7/site-packages/redis/client.py in __repr__(self)
    745
    746     def __repr__(self):
--> 747         return "%s<%s>" % (type(self).__name__, repr(self.connection_pool))
    748
    749     def set_response_callback(self, command, callback):

/usr/local/lib/python3.7/site-packages/redis/connection.py in __repr__(self)
   1098         return "%s<%s>" % (
   1099             type(self).__name__,
-> 1100             repr(self.connection_class(**self.connection_kwargs)),
   1101         )
   1102

/usr/local/lib/python3.7/site-packages/redis/connection.py in __repr__(self)
    520
    521     def __repr__(self):
--> 522         repr_args = ','.join(['%s=%s' % (k, v) for k, v in self.repr_pieces()])
    523         return '%s<%s>' % (self.__class__.__name__, repr_args)
    524

/usr/local/lib/python3.7/site-packages/redis/connection.py in repr_pieces(self)
    525     def repr_pieces(self):
    526         pieces = [
--> 527             ('host', self.host),
    528             ('port', self.port),
    529             ('db', self.db)

AttributeError: 'FakeConnection' object has no attribute 'host'

Is this with master or the last release? I've recently fixed a similar bug (#262) but not gotten around to putting it in a release.

This is fixed in 1.2.1.