Skip to content

Correctly loading the methods from relatively imported classes - #364

Merged
zabil merged 16 commits into
getgauge:masterfrom
kunalvishwasrao:feature/correctly-load-impl-methods-from-classes
Jul 6, 2024
Merged

zabil merged 16 commits into
getgauge:masterfrom
kunalvishwasrao:feature/correctly-load-impl-methods-from-classes

Conversation

@kunalvishwasrao

@kunalvishwasrao kunalvishwasrao commented Jul 2, 2024 •

Copy link
Copy Markdown
Contributor

After merging #360 all the previous issues were fixed but when I created step implementations inside a class and tried use those steps inside specs, I was getting an error with positional arguments missing.

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 the relative file path into an absolute file path inside update_step_resgistry_with_class() method #365

Hey @bugdiver, @zabil, can you please help me merge this PR to resolve this issue.
Apologies for this follow-up PR, missed this update in the previous PR.

Thanks!😄

Comment thread getgauge/impl_loader.py Outdated
@zabil

zabil commented Jul 3, 2024

Copy link
Copy Markdown
Member

I'll take a look at this. Thanks for raising #360 will use the info to test it locally.

@kunalvishwasrao

Copy link
Copy Markdown
Contributor Author

I'll take a look at this. Thanks for raising #360 will use the info to test it locally.

Sure, thanks a lot @zabil😄

@chadlwilson

Copy link
Copy Markdown
Contributor

It seems pretty clear to me that this code needs automated tests or this is going to be broken again at some point. Is there any reason it can't be tested?

@kunalvishwasrao
kunalvishwasrao force-pushed the feature/correctly-load-impl-methods-from-classes branch from eeef098 to 4161583 Compare July 3, 2024 13:46
dependabot Bot and others added 6 commits July 3, 2024 19:26
Bumps the pip-dependencies group with 2 updates: [importlib-metadata](https://github.com/python/importlib_metadata) and [setuptools](https://github.com/pypa/setuptools).

Updates `importlib-metadata` from 7.1.0 to 7.2.1
- [Release notes](https://github.com/python/importlib_metadata/releases)
- [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst)
- [Commits](python/importlib_metadata@v7.1.0...v7.2.1)

Updates `setuptools` from 70.0.0 to 70.1.0
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](pypa/setuptools@v70.0.0...v70.1.0)

---
updated-dependencies:
- dependency-name: importlib-metadata
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: pip-dependencies
- dependency-name: setuptools
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: pip-dependencies
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Kunal Vishwasrao <[email protected]>
…tgauge#362)

Bumps the pip-dependencies group with 3 updates in the / directory: [debugpy](https://github.com/microsoft/debugpy), [importlib-metadata](https://github.com/python/importlib_metadata) and [setuptools](https://github.com/pypa/setuptools).

Updates `debugpy` from 1.8.1 to 1.8.2
- [Release notes](https://github.com/microsoft/debugpy/releases)
- [Commits](microsoft/debugpy@v1.8.1...v1.8.2)

Updates `importlib-metadata` from 7.2.1 to 8.0.0
- [Release notes](https://github.com/python/importlib_metadata/releases)
- [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst)
- [Commits](python/importlib_metadata@v7.2.1...v8.0.0)

Updates `setuptools` from 70.1.0 to 70.1.1
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](pypa/setuptools@v70.1.0...v70.1.1)

---
updated-dependencies:
- dependency-name: debugpy
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: pip-dependencies
- dependency-name: importlib-metadata
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: pip-dependencies
- dependency-name: setuptools
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: pip-dependencies
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Kunal Vishwasrao <[email protected]>
Signed-off-by: BugDiver <[email protected]>
Signed-off-by: Kunal Vishwasrao <[email protected]>
Correctly loading the methods from relatively imported classes (getgauge#365)

Signed-off-by: Kunal Vishwasrao <[email protected]>

Co-authored-by: Zabil Cheriya Maliackal <[email protected]>
Signed-off-by: Kunal Vishwasrao <[email protected]>
@kunalvishwasrao
kunalvishwasrao force-pushed the feature/correctly-load-impl-methods-from-classes branch from f6ef53b to bf770bf Compare July 3, 2024 13:56
@zabil

zabil commented Jul 3, 2024

Copy link
Copy Markdown
Member

Yeah I agree. I am having a tough time testing it locally at the moment because the install scripts are not working as expected and there are some python version issues.

@kunalvishwasrao is there a way you can look into some unit tests for this logic?

@kunalvishwasrao

Copy link
Copy Markdown
Contributor Author

Yeah sure @zabil I'll look into unit tests for testing this logic.
Thanks 😄

@kunalvishwasrao

Copy link
Copy Markdown
Contributor Author

Hey @zabil,

I've added a unittest file to test the update_step_resgistry_with_class() method for relative imports of methods inside a class as well as outside as suggested. Can you please review it and let me know if its fine.

Thanks!😄

Comment thread getgauge/impl_loader.py
Comment thread tests/test_impl_loader.py Outdated
os.chdir('tests')
method_list = update_step_resgistry_with_class(Sample(), self.relative_file_path)
os.chdir(curr_dir)
self.assertEqual(2, len(method_list))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertEqual(2, len(method_list))
self.assertEqual(["Greet <name> from inside the class",
"Greet <name> from outside the class"],
[method.step_text for method in method_list])```
Will be good to make this assertion specific

Comment thread tests/test_impl_loader.py Outdated
def test_update_step_resgistry_with_class(self):
curr_dir = os.getcwd()
os.chdir('tests')
method_list = update_step_resgistry_with_class(Sample(), self.relative_file_path)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
method_list = update_step_resgistry_with_class(Sample(), self.relative_file_path)
method_list = update_step_registry_with_class(Sample(), self.relative_file_path)

I understand this is not related to you change but will be a good time to fix the typo in the test and the implementation, if that's ok.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sure, will do it 😄

@kunalvishwasrao

Copy link
Copy Markdown
Contributor Author

Hey @zabil,

Updated the method name and unttests as suggested. Can you please let me know if it looks fine.

Thank!😄

@gaugebot

gaugebot Bot commented Jul 5, 2024

Copy link
Copy Markdown

@kunalvishwasrao Thank you for contributing to gauge-python. Your pull request has been labeled as a release candidate 🎉🎉.

Merging this PR will trigger a release.

Please bump up the version as part of this PR.

Instructions to bump the version can found at CONTRIBUTING.md

If the CONTRIBUTING.md file does not exist or does not include instructions about bumping up the version, please looks previous commits in git history to see what changes need to be done.

@kunalvishwasrao

Copy link
Copy Markdown
Contributor Author

Hey @zabil,

Thanks for the review and approval!😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants