barseghyanartur / django-elasticsearch-dsl-drf

Integrate Elasticsearch DSL with Django REST framework.
https://pypi.python.org/pypi/django-elasticsearch-dsl-drf
370 stars 117 forks source link

Unicode literals in examples/simple/factories/constants.py breaks test under python 2 #128

Closed ar7n closed 5 years ago

ar7n commented 5 years ago

I was trying to run tests with tox and i have got such error with py27-django18 env:

SerializationError: ({'publication_date': datetime.date(2010, 6, 5), 'state': 'published', 'summary': "Alice spots another creature in the pool, swimming far off. She sees that it is a mouse, who has also slipped into the pool of tears. Alice thinks she might as well try speaking to the mouse but he doesn't seem to understand English, so she tries addressing him in French. The first phrase she thinks of is \xe2\x80\x9cOu est ma chatte?\xe2\x80\x9c which means \xe2\x80\x9cWhere is my cat?\xe2\x80\x9c The mouse is suitably unnerved. Alice protests that the mouse would like her cat, Dinah, and proceeds to list her virtues. The mouse is very offended.", 'tags': [], 'id': 443, 'price': Decimal('96.16'), 'pages': 200, 'null_field': None, 'authors': [], 'stock_count': 30, 'description': 'As she said these words her foot slipped, and in another moment, splash! she was up to her chin in salt water. Her first idea was that she had somehow fallen into the sea, \xe2\x80\x98and in that case I can go back by railway,\xe2\x80\x99 she said to herself. (Alice had been to the seaside once in her life, and had come to the general conclusion, that wherever you go to on the English coast you find a number of bathing machines in the sea, some children digging in the sand with wooden spades, then a row of lodging houses, and behind them a railway station.) However, she soon made out that she was in the pool of tears which she had wept when she was nine feet high.', 'isbn': u'978-1-74756-426-0', 'title': 'CHAPTER II. The Pool of Tears.', 'publisher': u'Mathurin, Pastoors and van den Nieuwenhuijsen', 'created': datetime.datetime(2019, 4, 19, 15, 14, 9, 407858, tzinfo=<UTC>)}, UnicodeDecodeError('ascii', '"Alice spots another creature in the pool, swimming far off. She sees that it is a mouse, who has also slipped into the pool of tears. Alice thinks she might as well try speaking to the mouse but he doesn\'t seem to understand English, so she tries addressing him in French. The first phrase she thinks of is \xe2\x80\x9cOu est ma chatte?\xe2\x80\x9c which means \xe2\x80\x9cWhere is my cat?\xe2\x80\x9c The mouse is suitably unnerved. Alice protests that the mouse would like her cat, Dinah, and proceeds to list her virtues. The mouse is very offended."', 308, 309, 'ordinal not in range(128)'))

The reason for this error is unicode literals in strings in file examples/simple/factories/constants.py. Simplest way to fix it - add from __future__ import unicode_literals import to file. I can make PR.

barseghyanartur commented 5 years ago

Strange. Tests pass at my place for all envs.

barseghyanartur commented 5 years ago

@ar7n:

What's your operating system?

ar7n commented 5 years ago

@barseghyanartur macOS Mojave 10.14.4

barseghyanartur commented 5 years ago

@ar7n:

I can't test it on Mac (since I don't have one), but go on with pull request. If that's how it works for everyone, let it be so.

barseghyanartur commented 5 years ago

Any progress on this?

barseghyanartur commented 5 years ago

@ar7n:

Thanks!