You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ WARN ] Imported library 'json' contains no keywords. #2611
I am seeing the following error in json library when running tests in Python 3 (the same test works fine in Python 2.7). [ WARN ] Imported library 'json' contains no keywords.
To reproduce:
Create use_json_dump.robot file with the following content:
*** Settings ***
Library json
*** Test Cases ***
Test title
${dictionary} Create Dictionary json_dumps=yes
Log ${dictionary}
${dumped} json.Dumps ${dictionary}
Log ${dumped}
c:\tests>robot use_json_dump.robot
c:\program files\python\lib\runpy.py:125: RuntimeWarning: 'robot.run' found in
ys.modules after import of package 'robot', but prior to execution of 'robot.ru
'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
[ WARN ] Imported library 'json' contains no keywords.
==============================================================================
Use Json Dump
==============================================================================
Test title | FAIL |
No keyword with name 'json.Dumps' found.
------------------------------------------------------------------------------
Use Json Dump | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
The reason seems to be that functions in the json module got keyword-only arguments in Python 3.6 and currently Robot Framework doesn't support them. There's already issue #2555 about adding support for them, but I wasn't aware that currently using them silently makes Robot to ignore keywords. Need to see could support for them added already in RF 3.0.3. If not, need to at least make it more visible that the syntax isn't currently supported and fix the problem in RF 3.1. I'll add a note about this to the aforementioned issue.
As a workaround you can switch to Python 3.5 or older where json doesn't use keyword-only arguments. Alternatively you could implement your own JSONLibrary that implements functions you need without keyword-only arguments by using the json module internally.
Activity
pekkaklarck commentedon May 31, 2017
The reason seems to be that functions in the
jsonmodule got keyword-only arguments in Python 3.6 and currently Robot Framework doesn't support them. There's already issue #2555 about adding support for them, but I wasn't aware that currently using them silently makes Robot to ignore keywords. Need to see could support for them added already in RF 3.0.3. If not, need to at least make it more visible that the syntax isn't currently supported and fix the problem in RF 3.1. I'll add a note about this to the aforementioned issue.As a workaround you can switch to Python 3.5 or older where
jsondoesn't use keyword-only arguments. Alternatively you could implement your ownJSONLibrarythat implements functions you need without keyword-only arguments by using thejsonmodule internally.ldiary commentedon Jun 1, 2017
Thanks for providing the workaround! I will write my own JSONLibrary then.
pekkaklarck commentedon Oct 19, 2018
This issue was fixed in RF 3.0.3 by #2627. Real support for keyword-only arguments was added in RF 3.1 by #2555.