Skip to content

Unable to reuse step implementations from another project #359

Closed
@kunalvishwasrao

Description

@kunalvishwasrao

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:

  1. Initialize 2 gauge projects with gauge init python command
  2. Setup the python.properties file like shown above
  3. Create a spec file with one step from current project and one from another project
  4. Run the spec
  5. 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 😄

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