mock-server
mock-server copied to clipboard
Error: NameError: name 'unicode' is not defined
I am running in python 3.7. Encountering the following error when trying to create an endpoint
Uncaught exception GET /__manage (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/__manage', version='HTTP/1.1', remote_ip='::1', headers={'Host': 'localhost:8888', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36', 'Sec-Fetch-Dest': 'document', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-User': '?1', 'Referer': 'http://localhost:8888/__manage/create?url_path=&method=GET&status_code=200&format=json', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'csrftoken=MWWmqR1DGiHkAML7zrz1n0eoVdnlEkELXnj2PsqgbxxCZOlNCvbxzwSx3E0YGt0T; Pastease.passive.chance.kfzz9br7dC3Qwzl=1; Pastease.passive.activated.kfzz9br7dC3Qwzl=0; _ga=GA1.1.1041436616.1576026813; _xsrf=2|850e85be|11696f0fd78a46e6d9b1483a4522d35e|1583298649'})
Traceback (most recent call last):
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/tornado/web.py", line 1443, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/handlers.py", line 372, in get
paths = resources_loader.load()
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 34, in load
for item in os.walk(self.api_dir)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 35, in <listcomp>
if self._check_folder(item)]
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 55, in _complete_path
url_path = UrlPath(get_url_path(item[0][len(self.api_dir):]))
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 107, in __init__
self.id = slugify(self.path)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/util.py", line 47, in slugify
slug = unicodedata.normalize("NFKD", unicode(value)).encode("ascii", "ignore")
NameError: name 'unicode' is not defined
Python 3 renamed the unicode
type to str
, the old str
type has been replaced by bytes
Hi, I am interested to use the server with python 3.7.*
as well, are there any updates on this issue? Thank you.
me too
Im using the same version and the error is still there.. :(
Actually it seems like a bug, because even on Python 3.9 I have the same error
Is this project nor maintained anymore? Will this issue be resolved ever?
hey folks 👋 I've opened #41 that addresses this issue.
give it a look. let me know what you think. the changes therein allowed me to use this library with both the python2 and python3 interpreters.
cc @tomashanacek <-- very interested in this getting merged 🙏