Skip to content

[ WARN ] Imported library 'json' contains no keywords. #2611

Closed

Description

@ldiary

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:

  1. 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}
  1. Install robot framework and run the test.
pip install robotframework    
robot user_json_dump.robot

Result in Python 3:

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
==============================================================================

Activity

  1. pekkaklarck commented on May 31, 2017

    @pekkaklarck
    Member

    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.

  2. ldiary commented on Jun 1, 2017

    @ldiary
    Author

    Thanks for providing the workaround! I will write my own JSONLibrary then.

  3. pekkaklarck commented on Oct 19, 2018

    @pekkaklarck
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions