I am trying to import ddt module to my test but getting error

Asked by Ali Ahmed

I am trying to import ddt module to my test but I am getting this error.

[error] script [ sikulitemp-12746970090261599471 ] stopped with error in line 8
[error] ImportError ( No module named ddt )
[error] --- Traceback --- error source first
line: module ( function ) statement
8: main ( <module> ) from ddt import ddt, data, unpack
[error] --- Traceback --- end --------------

how do I import this to sikuli?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Python modules must be compatible with Jython 2.7 (written in Python language only, no native C-based parts).

See here for usage:
https://sikulix-2014.readthedocs.io/en/latest/scenarios.html#access-python-packages-from-sikulix-scripts-run-by-sikulix-gui-or-commandline

Revision history for this message
Ali Ahmed (ali13xii) said :
#2

I'm looking at the code on github and it looks like they only used python to script
https://github.com/datadriventests/ddt and in doc it says it should work for Python 2.7

Revision history for this message
RaiMan (raimund-hocke) said :
#3

--- General remark:
If you want to do more complex things in SikuliX, then you have to fully understand Python/Jython.
When you want to use Python modules, that are not registered with SikuliX, then you have to find out your self, wether they run with SikuliX/Jython 2.7
You have to understand, how to make Python modules ready for SikuliX/Jython.

All this is not something that is supported here for every aspect of a special Python module.
The net might have more sources to help you in a special case.

In doubt you have to dive into the code of the module and understand structure, features and dependencies.

--- Your case ddt:
I had a look into it.
ddt depends on enum, which for 2.7 is only available as PyPi module.
If you succeed in making this available in the SikuliX context together with ddt.py, then it might work.

BE aware: all the setup stuff with Python might work in a Jython installation too (which is not the case with a simple sikulixide-jar usage). So you might install a module in a Python 2.7 context and then copy the relevant py files/folders into the SikuliX context or setup references to the Python stuff (see comment #1)

Can you help with this problem?

Provide an answer of your own, or ask Ali Ahmed for more information if necessary.

To post a message you must log in.