robotframework-httplibrary
robotframework-httplibrary copied to clipboard
Import failing on Python 3.6
There's an unsupported syntax in HttpLibrary init.py
except ValueError, e:
is not supported in Python 3.6 (maybe other versions as well, not sure). Updating to
except ValueError as e:
works for Python 2.7 and above (maybe for lower versions of Python as well, not sure).
Also:
from urllib import urlparse
becomes
from urllib.parse import urlparse
and it's failing on importing livetest
.
Tried from HttpLibrary import livetest
but that's not working.
Ok, got the imports for Python 3.6:
-
__init__.py
from robot.api import logger
from base64 import b64encode
from functools import wraps
from urllib.parse import urlparse
from HttpLibrary import livetest
import json
import jsonpointer
import jsonpatch
-
livetest.py
import sys
import webtest
import http.client
from urllib.parse import urlparse
from http.cookies import BaseCookie, CookieError
from six.moves import http_cookiejar
conn_classes = {'http': http.client.HTTPConnection,
'https': http.client.HTTPSConnection}
Also in livetest.py
, line 121: iteritems()
should be updated to items()
headers = dict((name, val) for name, val in req.headers.items())
hey @joaonc I am having the same issues. Do we need to make all changes for the library to work ?
@aks1589 I'm pretty sure this is a defunct project and will never work in Python 3.x unless someone picks it up.
What we're doing is we're moving away from using this library altogether and have our own layer in Python (and imported as a library) that does the REST calls, using Python's requests
library.
thanks for the reply @joaonc ! Thats disappointing considering the functions this library had to offer. I am now using the requests library for my test cases.
Any updates on this? Im using now Python 3.7 and the issue is still on it
@jmagaru I don't think there will be any updates on this as this seems to be a defunct project. My recommendation is that you don't use this library.
@joaonc Have you any recommendations instead this library?
@pablogiroud I don't know. Maybe Robot Framework already provides some functionality in its libraries.
What I did was created a Python module using the requests package, which makes doing REST calls super easy, and imported it into Robot as a library.
Yes request library looks easy to use. https://github.com/bulkan/robotframework-requests
thanks @joaonc and @jmagaru !!!
@peritus , Is there a plan to support this library for Python 3.x?
Can someone help me also i am getting this error
Importing test library 'HttpLibrary.HTTP' failed: SyntaxError: invalid syntax (__init__.py, line 16) Traceback (most recent call last)
pip list installed
Package Version
asn1crypto 0.24.0
beautifulsoup4 4.7.1
certifi 2019.3.9
cffi 1.12.2
chardet 3.0.4
cryptography 2.6.1
idna 2.8
ipaddress 1.0.22
jsonpatch 1.23
jsonpointer 2.0
pip 19.0.3
pycparser 2.19
pyOpenSSL 19.0.0
robotframework 3.1.1
robotframework-httplibrary 0.4.2
robotframework-seleniumlibrary 3.3.1
selenium 3.141.0
setuptools 39.1.0
six 1.12.0
soupsieve 1.9
urllib3 1.24.1
waitress 1.2.1
WebOb 1.8.5
WebTest 2.0.33
`
i am getting the same error,please to help me
20191114 09:22:58.857 [WARN]: Importing test library "HttpLibrary" failed
Traceback (most recent call last):
Importing test library 'HttpLibrary' failed: SyntaxError: invalid syntax (__init__.py, line 16)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/lib/robot/utils/importer.py", line 153, in _import
return __import__(name, fromlist=fromlist)
PYTHONPATH:
/usr/local/bin
/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/spec
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/lib
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/contrib/testrunner/../../lib
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/contrib/testrunner/../../lib
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/spec/librarymanager.py", line 87, in _fetch_keywords
return get_import_result(path, library_args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/spec/libraryfetcher.py", line 24, in get_import_result
lib = robotapi.TestLibrary(path, args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/lib/robot/running/testlibraries.py", line 50, in TestLibrary
return_source=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/lib/robot/utils/importer.py", line 72, in import_class_or_module
self._raise_import_failed(name, err)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/robotide/lib/robot/utils/importer.py", line 109, in _raise_import_failed
raise DataError('\n'.join(msg))
I have the same issue.
but i have install HttpLibrary.HTTP.
robotframework (3.1.2) robotframework-httplibrary (0.4.2) robotframework-requests (0.6.2) robotframework-ride (1.7.4a1) robotframework-selenium2library (3.0.0) robotframework-seleniumlibrary (4.1.0) robotframework-seriallibrary (0.3.1) robotframework-sshlibrary (3.4.0)
`20191217 16:04:52.554 [WARN]: Importing test library "HttpLibrary.HTTP" failed
Traceback (most recent call last): Importing test library 'HttpLibrary.HTTP' failed: SyntaxError: invalid syntax (init.py, line 16) Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/robotide/lib/robot/utils/importer.py", line 153, in _import return import(name, fromlist=fromlist) PYTHONPATH: /usr/lib/python36.zip /usr/lib/python3.6 /usr/lib/python3.6/lib-dynload /home/zhaobin/.local/lib/python3.6/site-packages /usr/local/lib/python3.6/dist-packages /usr/lib/python3/dist-packages /usr/local/lib/python3.6/dist-packages/robotide/spec /usr/local/lib/python3.6/dist-packages/robotide/lib /usr/local/lib/python3.6/dist-packages/robotide/spec /usr/local/lib/python3.6/dist-packages/robotide/lib /usr/local/lib/python3.6/dist-packages/robotide/contrib/testrunner/../../lib /usr/local/lib/python3.6/dist-packages/robotide/contrib/testrunner/../../lib File "/usr/local/lib/python3.6/dist-packages/robotide/spec/librarymanager.py", line 87, in _fetch_keywords return get_import_result(path, library_args) File "/usr/local/lib/python3.6/dist-packages/robotide/spec/libraryfetcher.py", line 24, in get_import_result lib = robotapi.TestLibrary(path, args) File "/usr/local/lib/python3.6/dist-packages/robotide/lib/robot/running/testlibraries.py", line 50, in TestLibrary return_source=True) File "/usr/local/lib/python3.6/dist-packages/robotide/lib/robot/utils/importer.py", line 72, in import_class_or_module self._raise_import_failed(name, err) File "/usr/local/lib/python3.6/dist-packages/robotide/lib/robot/utils/importer.py", line 109, in _raise_import_failed raise DataError('\n'.join(msg)) `
Thanks to Author of this library. One of the best API library to use in Robot framework especially with session retained for subsequent requests in page object test automation model. This is not achievable using other libraries. So thought of fixing issues with this library for Python 3 and I was successful and it is working.
Python version I tried is python 3.8.1. As I do not know how to build test library for robot framework, someone here especially author could publish HTTPLIBRARY with latest attached files to support Python 3.
Note: install relevant libraries (pyparsing, urllib3, webtest) needed for this files.
Inside Zip files, there are 3 files, httplibs (previously init.py file in library), livetest and httprequest. Use only httplibs and livetest to build library.
Whereas, httprequest python file can be imported to robotframework and could use keywords as temporary solution until library available.
is this library not to be used? I am also getting same error Importing test library 'HttpLibrary.HTTP' failed: SyntaxError: invalid syntax (init.py, line 16)