Description:
After merging #360 all the previous issues regarding relatively importing step implementations from another project were fixed but when I created step implementations inside a class in different project and tried use those steps inside specs by using the relative import feature, I am getting an error saying missing 1 required positional argument despite of having everything correctly present.
Gauge-Main-Project/step_impl/step_impl.py
from getgauge.python import step, Messages
class BaseMainClass:
def __init__(self) -> None:
pass
class MainClass(BaseMainClass):
@step("Greet <name> from Main Project")
def greet_main_project(self, name):
print(f"Hello from the Main Project, {name}")
Messages.write_message(f"Hello from the Main Project - {name}")
Gauge-Sub-Project/step_impl/step_impl.py
from getgauge.python import step, Messages
class BaseSubClass:
def __init__(self) -> None:
pass
class SubClass(BaseSubClass):
@step("Greet <name> from Sub Project")
def greet_sub_project(sub, name):
print(f"Hello from the Sub Project, {name}")
Messages.write_message(f"Hello from the Main Project - {name}")
Sample Spec File
# Test Relative Imports
> Sample spec from Sub Project
## Test Relative Imports From Class
* Greet "Kunal" from Sub Project
* Greet "Kunal" from Main Project
To Reproduce:
Steps (or project) to reproduce the behavior:
Initialize 2 gauge projects with gauge init python command
Update the step_impl.py files for both the projects like shown above
Setup the Gauge-Sub-Project/env/default/python.properties file like: STEP_IMPL_DIR = step_impl, ../Gauge-Main-Project/step_impl
Create a spec file with the above mentioned steps
Run the spec
See error
Logs
Traceback (most recent call last):
File "<PATH_TO_VENV>\Lib\site-packages\getgauge\executor.py", line 33, in execute_method
step.impl(*params)
TypeError: MainClass.greet_main_project() missing 1 required positional argument: 'name'
Possible Fix:
This issue arises because the update_step_resgistry_with_class() method inside the impl_loader.py file is unable to fetch all the methods inside that step implementation file inside get_all_methods_in() method due to the file_path being a relative file path.
Resolving this relative file path into an absolute file path fixes this issue.
Description: After merging #360 all the previous issues regarding relatively importing step implementations from another project were fixed but when I created step implementations inside a class in different project and tried use those steps inside specs by using the relative import feature, I am getting an error saying
missing 1 required positional argument
despite of having everything correctly present.Gauge-Main-Project/step_impl/step_impl.py
Gauge-Sub-Project/step_impl/step_impl.py
Sample Spec File
To Reproduce: Steps (or project) to reproduce the behavior:
gauge init python
commandstep_impl.py
files for both the projects like shown aboveGauge-Sub-Project/env/default/python.properties
file like:STEP_IMPL_DIR = step_impl, ../Gauge-Main-Project/step_impl
Logs
Possible Fix: This issue arises because the
update_step_resgistry_with_class()
method inside theimpl_loader.py
file is unable to fetch all the methods inside that step implementation file insideget_all_methods_in()
method due to thefile_path
being a relative file path. Resolving this relative file path into an absolute file path fixes this issue.Versions:
Windows 10 (10.0.19045)
3.11.4
1.6.7
Project Structure:
Thanks!😄