Repository navigation
Description
Description:
I have 2 Gauge projects - Gauge-Project-Main and Gauge-Project-Sub. I want to use the step implementations created within Gauge-Project-Main inside Gauge-Project-Sub. To do so, I have tried updating the Gauge-Project-Sub's env/default/python.properties file with both absolute and relative paths to Gauge-Project-Main's step_impl folder but I keep getting different errors in both scenarios:
Adding relative path to python.properties file:
STEP_IMPL_DIR = step_impl, ../Gauge-Main-Project/step_impl
26-06-2024 18:34:44.479 [python] [CRITICAL] Exception occurred while loading step implementations from file: ..\Gauge-Main-Project\step_impl\step_impl.py.
Traceback (most recent call last):
File "<PYTHON_VENV_PATH>\Lib\site-packages\getgauge\impl_loader.py", line 65, in import_file
m = importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\AppData\Local\Programs\Python\Python311\Lib\importlib_init.py", line 121, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '...Gauge-Main-Project.step_impl.step_impl'
Adding absolute path to python.properties file:
STEP_IMPL_DIR = step_impl, <ABSOLUTE_PATH_TO_PROJECT>/Gauge-Main-Project/step_impl
Traceback (most recent call last):
File "<PYTHON_VENV_PATH>\Lib\site-packages\getgauge\executor.py", line 32, in execute_method
params = _get_args(params, step)
^^^^^^^^^^^^^^^^^^^^^^^
File "<PYTHON_VENV_PATH>\Lib\site-packages\getgauge\executor.py", line 50, in _get_args
args_length = len(inspect.signature(hook_or_step.impl).parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 3280, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 3028, in from_callable
return _signature_from_callable(obj, sigcls=cls,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\AppData\Local\Programs\Python\Python311\Lib\inspect.py", line 2449, in _signature_from_callable
raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: None is not a callable object
To Reproduce
Steps (or project) to reproduce the behavior:
- Initialize 2 gauge projects with
gauge init pythoncommand - Setup the python.properties file like shown above
- Create a spec file with one step from current project and one from another project
- Run the spec
- See error
Versions:
- OS -
Windows 10 (10.0.19045) - Python version -
3.11.4 - Gauge version -
1.6.7
Project Structure:
Project-Root
├── Gauge-Main-Project
│ ├── env
│ │ └── default
│ │ └── default.properties
│ │ └── python.properties
│ ├── specs
│ │ └── example.spec
│ └── step_impl
│ └── step_impl.py
│
└── Gauge-Sub-Project
├── env
│ └── default
│ └── default.properties
│ └── python.properties
├── specs
│ └── example.spec
└── step_impl
└── step_impl.py
Thanks 😄
Activity
chadlwilson commentedon Jun 26, 2024
Are you sure you didn't just typo things? Your tree structure shows
Gauge-Project-Mainwhereas your config showsGauge-Main-ProjectOther than that, I have a feeling that might not work, and you might want to instead try to organise your projects and config differently to avoid paths like that, and be able to run from the root as working directly with different other config. On Linux/Mac you could probably just symlink, but not going to send you down the path of junction points on Windows....
kunalvishwasrao commentedon Jun 26, 2024
Hello @chadlwilson,
Apologies for the typo in the tree structure (will update it). Its actually correctly mentioned in the config as
Gauge-Main-Project, despite of which it doesn't seem to work. Re-organizing the project will be the last resort, please let me know if you come across any solution.Thanks.😄
chadlwilson commentedon Jun 26, 2024
I'm not an expert with python or the python plugin, but from the errors it looks like it is translaring the impl dirs to packages directly, so suspect only regular forward paths will work.
bugdiver commentedon Jun 26, 2024
I just tried to test it quickly, and It's working as expected on macOS. Unfortunately I don't have access to windows device ATM, so can't say if it's windows specific issue
kunalvishwasrao commentedon Jun 26, 2024
Hello @bugdiver,
The path format that worked for you on macOS, was it an absolute path or relative path in the
STEP_IMPL_DIRvariable?chadlwilson commentedon Jun 26, 2024
Did the relative or absolute case work for you? I wonder if it makes any difference as to direction of slashes :-)
The code on the python side is:
gauge-python/getgauge/impl_loader.py
Lines 52 to 66 in 410a097
Didn't look to me like it'd work in either case unless the base path is the root (not the subproject)
bugdiver commentedon Jun 26, 2024
Forget what I said earlier, I'm able to see the error on macOS as well. I will try to look into the issue