Skip to content

**kwargs support for dynamic test libraries #1500

Closed

Description

@spooning

Originally submitted to Google Code by zimmermann.code on 6 Aug 2013

Robot Framework 2.8.x introduces **kwargs support for Test Library Keywords (to pass a dictionary to the Keyword which contains all name=value arguments from the Keyword call that can't be mapped to the Keyword's positional parameters, just like it works with normal Python functions).

This support is still missing for Dynamic Test Libraries.

I created a project fork to implement this:

https://bitbucket.org/userzimmermann/robotframework

These are the actual changes:

https://bitbucket.org/userzimmermann/robotframework/compare/default..c3496bdb19c0#diff

It's already working. It just needs some additional minor changes and some more tests, as discussed in the #robotframework IRC channel at freenode.net.
Here is the log (14:01 - 15:32):

http://koti.kapsi.fi/~peke/irclogs/robotframework/2013-08-06.log.html

Activity

  1. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 Aug 2013

    This looks very good already! Tasks to do:

    1. Enhance and clean-up code a little. This was discussed in IRC.
    2. Add more tests. Including tests for **kwargs with Java based dynamic libraries.
    3. Documentation in User Guide.
  2. added this to the 2.8.2 milestone on Jun 30, 2014
  3. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 7 Aug 2013

    1. Done :)

    The diff link in the issue description always shows the complete changes (including the above).

  4. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 12 Sep 2013

    @⁠zimmermann.code: What's the situation with tasks 2) and 3)?

  5. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 12 Sep 2013

    Still in progress :(
    There just were so much other things to do the last weeks... other Robot things :)
    I will finish it in the beginning of next week.

  6. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 17 Sep 2013

    1. Almost done...

    I just looked for tests using DynamicLibrary implementations and started to add tests for analogous/derived DynamicLibraryWithKwargsSupport implementations, which also verify the same behavior as DynamicLibrary when using Keywords without **kwargs.

    This diff shows what I've done so far:

    https://bitbucket.org/userzimmermann/robotframework/compare/e54338e..f20bda9#diff

  7. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 18 Sep 2013

    The tests with DynamicLibraryWithKwargsSupport are done, hopefully :)

    https://bitbucket.org/userzimmermann/robotframework/compare/853a6e7..f20bda9#diff

    When trying to further adapt atest/testdata/test_libraries/dynamic_library_python.txt, I recognized that **kwargs handling doesn't work in a generic way if no get_keyword_arguments is defined, so i also added support for this:

    https://bitbucket.org/userzimmermann/robotframework/commits/d9ba198731cc1b4703d9255fcc26f2217ad1ff1c

  8. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor
  9. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor
  10. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 28 Sep 2013

    Took me a while to get used to Jython and making it run the atests.
    I never used Jython and barely used Java at all before... :)

    My Jython is a 2.5.2, which led to the exploration of some incompatibilities of my dynamic **kwargs support code with Python/Jython 2.5 (inspect.getargspec returns a plain tuple in 2.5), so I changed that parts to use PythonArgumentParser from robot.running.arguments:

    https://bitbucket.org/userzimmermann/robotframework/commits/821d5b0574a4b28d180e9c4f735a8d9ae0af22c5

    I also found some 2.5 incompatibilities in some general atest Python modules. I opened a separate issue 1531 for that.

    Now I will finally create the tests for Dynamic Java Test Libraries...

  11. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 7 Oct 2013

    Finished! :D

    The use of PythonArgumentParser mentioned in the last comment introduced an incompatibility with Dynamic Java Test Libraries, so I created a generic DynamicMethodArgumentParser for getting the argspec of Dynamic API methods, either Python or Java based:

    https://bitbucket.org/userzimmermann/robotframework/commits/431162f86164198ad16846336b83310813a4cca5

    I built the Java tests on the RunKeywordLibraryJava and ArgDocDynamicJavaLibrary classes by deriving classes with a "WithKwargsSupport" suffix. For the third runKeyword parameter I used the org.python.core.PyDictionary class. This needed a little fix in JavaArgumentParser:

    https://bitbucket.org/userzimmermann/robotframework/commits/7d96a121e6e7cfcedd7640e6168a85ef5521abf2

    All dynamic **kwargs tests are working fine with Python 2.5-2.7 and Jython 2.5, and, if you are interested, even with Python 3 in my python3 branch:

    https://bitbucket.org/userzimmermann/robotframework/commits/branch/python3

    I made the following additions to the documentation:

    https://bitbucket.org/userzimmermann/robotframework/commits/6edae790b59aecd5021f323c917ed58a3659e05c

    The final complete fork diff can be seen at this URL:

    https://bitbucket.org/userzimmermann/robotframework/compare/default..2044532#diff

    You can simply add my changes (without the other branches) by pulling with -B master from my repo and reverting the README.txt on merging.
    The changes also contain the fixes from issue 1531 . Should I revert them?

  12. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 8 Oct 2013

    Great! I'll take a look at this when I have time. Probably not today but hopefully this week. This stuff will definitely be included into 2.8.2 anyway.

    In my opinion changes related to issue 1531 can be reverted. I rather document that running atests requires Python 2.6 or newer.

  13. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor
  14. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by zimmermann.code on 14 Oct 2013

    ooops: utest! I always forget something ;)

    I made the necessary changes and added/extended tests for dynamic **kwargs support in:

    utest/running/test_handlers.py
    utest/running/test_testlibrary.py

    I also made some further additions to the atests.
    New complete fork diff (merged with latest robot commit):

    https://bitbucket.org/userzimmermann/robotframework/compare/master..b912f15#diff

  15. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 15 Nov 2013

    Finally starting to merge these changes. I was trying to pull changes directly from your fork, but I got also some unrelated stuff I would like to ignore. Changes to README are easy to handle somehow, but I don't want to pull your python3 branch.

    Do you have any idea what would be the easiest way to get only changes related to **kwargs with dynamic libs?

  16. 5 remaining items

  17. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 20 Nov 2013

    This issue was updated by revision a74fa38a0dd1.

    Cleaning up implementation and tests. Some more further cleanup still needed,
    but there are now TODOs about them.

    Docs not proofread at all yet.

  18. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 20 Nov 2013

    The code was merged in revision 3134960a8729. That commit contains everything pulled with hg pull <a href="https://bitbucket.org/userzimmermann/robotframework" rel="nofollow">https://bitbucket.org/userzimmermann/robotframework</a> -B master except for README.txt changes.

    We started cleaning up the code (including old code) in revision a74fa38a0dd1 and also added TODOs for further code and test cleanup. We'll continue with that work tomorrow.

    Documentation changes haven't been reviewed at all.

    Thanks a lot for your work Stefan! We were impressed with the changes you had done to code and tests. Most of the things that we want to cleanup are actually places where the old code/test was bad.

  19. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision 387e1cf4dc70.

    Combined invalid argspec tests.

  20. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision 3d9d713eb6b1.

    Further test cleanup

  21. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision 54ed6c9c33cf.

    Return '_varargs, *_kwargs' and not '_unknown, *_kwargs' if there is no arg spec.

  22. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision e3ae9ca64a98.

    Refactored detecting does run_keyword support **kwargs. Now RunKeyword knows it and we also got rid off DynamicMethodArgumentParser.

    We did some changes to internal APIs to make the code cleaner, but those changes should not matter to anyone using Robot.

    We have now gone through all the TODOs we added to tests and code while merging in the original code. Next up is reviewing the docs. After that this issue ought to be done. Comments from Stefan regarding to our changes are obviously welcome.

  23. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision 068200916073.

    Thought we run tests before last commit but apparently not. Fixed broken Java dynamic library support now.

  24. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 21 Nov 2013

    This issue was updated by revision 07aa2951ea02.

    Fixed unit test that didn't work with IronPython due to lambda.name differences.

  25. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 25 Nov 2013

    This issue was updated by revision 9d6aa4cb9bb6.

    Started reviewing/enhancing documentation. Work in progress.

  26. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 25 Nov 2013

    This issue was updated by revision afb1ca854f97.

    Enhanced docs and they are now ready for proofreading/review.

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions