Skip to content
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

Expose pytest integration as a plugin #1526

Closed
vodik opened this issue Mar 11, 2018 · 5 comments
Closed

Expose pytest integration as a plugin #1526

vodik opened this issue Mar 11, 2018 · 5 comments
Labels

Comments

@vodik
Copy link
Contributor

vodik commented Mar 11, 2018

So, was going to put this off until I got some of my other ideas completed, but someone just opened an issue on an old project I started the last time I was playing with Hy: vodik/hytest#1

That project was me fiddling with writing a pytest plugin that integrated Hy into pytest.

But we already do this. So, my proposal is to do the following:

  • Move the Hy specific logic out of conftest.py and move it somewhere inside the hy package (say hy.contrib.pytest_plugin)
  • Update conftest.py to use pytest_plugins = ['hy.contrib.pytest_plugin']

Now we have two options for exposing this to the general pytest community:

  1. Hy itself could register a pytest plugin directly as an entry_point.
  2. Publish another package under hylang organization called something like pytest-hy that registers a pytest plugin which contains a single line along the lines of:
from hy.contrib.pytest_plugin import *

I'm more in favour of the later, as its more explicit. It is also how I've seen other libraries do it, for example pytest-aiohttp

We could also promote a few useful functions like can_compile, can_eval, etc as pytest fixtures for other projects to reuse.

@Kodiologist
Copy link
Member

Sounds cool. I'd lean toward option 1 because otherwise we'd create a lot of organization and boilerplate (a GitHub repo, a PyPI package, etc.) for a one-liner. Users will already have to add "hy.contrib.pytest_plugin" to their pytest_plugins, which seems explicit to me.

I would name it hy.extra.pytest_plugin or just hy.pytest_plugin rather than hy.contrib.pytest_plugin.

@vodik
Copy link
Contributor Author

vodik commented Mar 12, 2018

We can start with option 1 and move to option 2 if it ever becomes a problem with it being a default.

@arjaz
Copy link

arjaz commented Mar 28, 2021

Hi!
I created a plugin for pytest for my needs which is based on the hy's conftest.py!
I'll be glad to see it integrated.

@Kodiologist
Copy link
Member

Cool, thanks. Perhaps we'll do that.

@Kodiologist
Copy link
Member

At this point, you can get pytest working with Hy with about 5 lines of configuration, so I've documented them on the wiki, and a plugin seems like overkill.

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

No branches or pull requests

4 participants