Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How do I import modules for Extension Tool in Jython

amurphy147
amurphy147 Posts: 18

Hello,

I'm trying to import a module in Jython but I'm getting some errors.

I first go to Windows > Preferences > PyDev > Interpreters > Jython Interpreters and add the jython.jar found in the installation URL: C:\Program Files\Parasoft\Test\9.10 for SOAtest & Virtualize\plugins\com.parasoft.xtest.scripting.eclipse.core_9.7.0.20161116\jython. I then add a Test and try importing any of the modules there and then get the following message:

Traceback (most recent call last):, File "", line 1, in , ImportError: No module named re,

I then set system properties with the jython.jar and jython/Lib paths

and get the following message:

Traceback (most recent call last):, File "", line 1, in , File "pyclasspath/re.py", line 7, in , File "pyclasspath/sre.py", line 17, in , File "pyclasspath/sre_compile.py", line 15, in , AssertionError: SRE module mismatch,

After, I installed Jython 2.7 and put the jython home and jython path on Parasoft > Preferences > Scripting and still get the same AssertionError message.

What can I do to import these modules successfully?

Thank you

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited March 2019

    What can I do to import these modules successfully?

    First, please undo the settings that you previously changed (click Restore Defaults on both pages). Next, follow the steps described here: Configuring Jython Preferences

    Typically, a user would download and install their own Jython 2.5.2 and then set "Jython Home" field to the path to that Jython installation. By doing this, SOAtest's internal Jython will automatically pick up an use any modules belonging to that other Jython installation's "Lib" directory. Additionally, if you have your own custom modules (.py files) in some other folder, then you can add that custom module folder in that "Jython Path" field. Please note that Jython version must be 2.5.2 and that you must also restart SOAtest after changing "Jython Home" or "Jython Path" fields.

  • amurphy147
    amurphy147 Posts: 18

    I switched to Jython 2.5.2, followed the documentation, and it works. You're the best, thank you.

  • amurphy147
    amurphy147 Posts: 18

    Sorry I got Jython 2.5.2 working, but is there a way to make Jython 2.7 work with SOAtest? As noted in my initial post I got a module mismatch error. Are there some files or folders I would need to remove from the SOAtest installation in order to avoid this error? After googling the error it seemed to relate with a conflict in installed Jython versions.

    Thank you again in advance.

  • jakubiak
    jakubiak Posts: 795 admin

    Unfortunately there is currently no way to make Jython 2.7 work with SOAtest. We have an internal feature request to support Jython 2.7, but we haven't implemented it yet due to a couple of known bugs in Jython 2.7 that make it difficult to integrate into SOAtest. Once Jython resolves those issues we hope to update Jython within SOAtest.

  • amurphy147
    amurphy147 Posts: 18

    Thank you very much for the response.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited March 2019

    Also see my previous answer to this same question which has a little more detail:
    Changing python version in Parasoft SoaTest

  • Benz27
    Benz27 Posts: 7
    edited October 2020

    Hello,
    I've already added the jython path in the preference, but still .py file is not working in the tool. Also, I'm not able to get the method name in the extension tool drop down. Can anyone please help me with this issue?

    Thanks!

  • Benz27
    Benz27 Posts: 7

    I've added jython as per below screenshot. Please let me know if this is the right way to update jython path

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited October 2020

    @Benz27, can you look at my previous answers? It looks like you are pointing your "Jython Home" to a Jython 2.7.2. I wrote why this won't work. You must point to a Jython 2.5.2 instead.

  • Benz27
    Benz27 Posts: 7

    Still I'm getting the same error. I installed jython 2.5.2 and updated the path

  • jakubiak
    jakubiak Posts: 795 admin

    What is the complete error message?

  • Benz27
    Benz27 Posts: 7

    Traceback (most recent call last):, File "", line 4, in , ImportError: No module named PythonLibrary,

  • Benz27
    Benz27 Posts: 7

    and another error message is

    Traceback (most recent call last):, File "", line 3, in , ImportError: No module named Functions,

    Thanks @jakubiak

  • Benz27
    Benz27 Posts: 7

    I'm trying to call python function using extension tool in Parasoft but it seems like something is missing.

  • jakubiak
    jakubiak Posts: 795 admin

    Is there any way you can show us the contents of your script?

  • Benz27
    Benz27 Posts: 7
    edited October 2020

    I updated the class path in system properties and it works.

    Thanks @jakubiak

  • jakubiak
    jakubiak Posts: 795 admin

    What is the "Functions" module? I can't seem to find it anywhere.