Skip to content

Incorporate pytest-gitlab plugin back into python-gitlab #3046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nejch opened this issue Nov 25, 2024 · 7 comments
Open

Incorporate pytest-gitlab plugin back into python-gitlab #3046

nejch opened this issue Nov 25, 2024 · 7 comments

Comments

@nejch
Copy link
Member

nejch commented Nov 25, 2024

Someone appears to have extracted our setup & fixtures for pytest and repackaged it all as a pytest plugin on pypi.org:

https://pypi.org/project/pytest-gitlab/

I was unaware of this but I have wanted something like this for years - i.e. expose our fixtures as a plugin to make them reusable in downstream projects. See https://gitlab.com/marge-org/marge-bot/-/merge_requests/479#note_2225265620 for a recent example use case.

I (and probably others @JohnVillalovos 😅 ) spent quite a few weekends adding and improving this pytest setup so IMO it would be nice to see the benefits of this shared here and also make it more discoverable for our users rather than have it a separate package that users might not trust if they can't recognize or see the sources.

I can't find the source for the project (seems to not be openly available though it reuses LGPL, purely by looking at the sdist). But I'll try to reach out to the author and see if we can incorporate it here. Otherwise the fixtures will almost definitely diverge anyway.

@JohnVillalovos
Copy link
Member

I hope it doesn't have some malware in the package!

The source should be in the *.whl and *.tar.gz: https://pypi.org/project/pytest-gitlab/0.3.1/#files

@nejch
Copy link
Member Author

nejch commented Nov 25, 2024

I found the sources now: https://gitlab.com/thht_science_software/pytest-gitlab

All looks good and in good faith. I just think it would make sense to have at least parts of that upstreamed back here and exposed along with the package. I've seen some libraries do this as well, providing their pytest plugins as a kind of public API.

Will reach out but not really a priority just yet :)

@JohnVillalovos
Copy link
Member

Yeah we could create a project under the namespace here. Maybe call it pytest-python-gitlab? or python-gitlab-pytest?

@nejch
Copy link
Member Author

nejch commented Nov 25, 2024

Sentry for example has sentry.testutils inside the package itself with a similar idea, so if we want to keep it lightweight we could even just move the reusable fixtures from our conftest and tests/ subdirs to gitlab/testing and then they get published along the package if add an entrypoint:

https://docs.pytest.org/en/stable/how-to/writing_plugins.html#making-your-plugin-installable-by-others

I've seen this pattern elsewhere but can't find other examples right now. But it would be the easiest for us and maybe also for the users (just one package to install).

We used to pack all our unit tests inside gitlab/ before migrating to pytest, so I'm sure people won't complain about a few extra KB 😀

@nejch
Copy link
Member Author

nejch commented Nov 26, 2024

Hey @thht 👋 I think that's you behind the pytest-gitlab project right?

Would you be interested in upstreaming some of the pytest plugin back here as part of the package? There's no rush and it's not a priority, just wanted to let you know before the projects diverge too much 🙇

@thht
Copy link

thht commented Nov 26, 2024

Hello there!
Yes, that's me. And yes, it would be great to get the code upstream. I'm a bit short on time right now. I can either start a branch and PR beginning of next year or help/contribute if somebody else started the effort.

And the project basically does what you describe in your comment plus it adds some convenience things.

@nejch
Copy link
Member Author

nejch commented Nov 26, 2024

That's perfect @thht, thanks. I'll also probably be on vacation around that time and will be back mid-January so we can follow up then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants