Skip to content

Split pytest plugins out into individual modules - #5770

Closed
Cadair wants to merge 1 commit into
astropy:masterfrom
Cadair:pytest_plugins
Closed

Cadair wants to merge 1 commit into
astropy:masterfrom
Cadair:pytest_plugins

Conversation

@Cadair

@Cadair Cadair commented Feb 3, 2017

Copy link
Copy Markdown
Member

This makes it possible for affiliated packages (SunPy) to use some of these options but not all of them.

@Cadair

Cadair commented Feb 9, 2017

Copy link
Copy Markdown
Member Author

@pllim I have just read your GSOC idea on splitting astropy test helper out into a seperate package. This is the first step in that I think.

@pllim

pllim commented Feb 9, 2017

Copy link
Copy Markdown
Member

I like the concept of making things more modular. I think there was a similar request from @josePhoenix a while back. However, CIs are failing.

@pllim pllim added this to the v2.0.0 milestone Feb 9, 2017
@Cadair

Cadair commented Feb 9, 2017

Copy link
Copy Markdown
Member Author

yeah this needs some more work (it's tied to sunpy/sunpy#1983) but it's not very high on my todo list unfortunately.

@pllim

pllim commented Feb 9, 2017

Copy link
Copy Markdown
Member

Okay, I'll make a note of this PR number in the GSoC idea, just in case. Thanks!

@Cadair

Cadair commented Feb 9, 2017

Copy link
Copy Markdown
Member Author

@pllim We moved the ideas to the open astronomy website, I added the PR and put myself up as a mentor while I was moving it ;)

@mohanagr

mohanagr commented Mar 8, 2017

Copy link
Copy Markdown
Contributor

@Cadair @pllim This is specifically the idea I was interested in. Can you please elaborate on how I can get involved? (As of now I'm working on [ #5799 #5858 ] ). Thanks.

@Cadair

Cadair commented Mar 8, 2017

Copy link
Copy Markdown
Member Author

Well this currently breaks all the CI builds as the split clearly hasn't been done cleanly enough.

The basic idea here is to move the "plugin" code out of the conftest.py file and into files that can be imported separately by packages that depend on astropy (or copied out of astropy altogether) and then configure astropy to use those plugins by specifying them in the conftest.py file.

@mohanagr

Copy link
Copy Markdown
Contributor

Also @pllim can you please tell me any small to-do's that I can begin with to start sorting this one out?


try:
import importlib.machinery as importlib_machinery
except ImportError: # Python 2.7

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.

@mohanagr , Travis CI indicates failures for Python 2.7. I suspect this is the cause here. So this PR needs to be patched to work in Python 2. Also, fix PEP8 test failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pllim I'm looking through these modules. These are the ones which were separated from conftest.py. Can you tell me what all additions are already planned to be made?

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.

Can you tell me what all additions are already planned to be made?

I am not sure if I understand the question. There is no planned addition if you mean additional keywords. But one of the proposed GSoC project is to separate out these pytest add-ons into a separate installable package that does not depend on Astropy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pllim yes about that, doesn't this PR do that? splitting into modules? I was working on python2 patch thing.

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.

This PR simply separates them into different modules. But the modules are still part of Astropy. The GSoC project is to create a separate package (something parallels to Astropy, not underneath it). Does this make sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh. Yes. Thanks. So as of now I model the changes in this PR that work with Python2 and submit another one?

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.

@mohanagr , yes, if you want to take over this work from @Cadair , you need to open a new PR from your own branch in your own fork. However, if possible, please credit @Cadair for the initial work before you apply your own changes. One way is to follow guidance given at #3558 (comment) (and a few comments that followed) on how to cherry pick commits from this PR. Hope this helps.

@mohanagr

mohanagr commented Mar 25, 2017 •

Copy link
Copy Markdown
Contributor

@Cadair I was a little confused as to why this project was given Intermediate/Advanced tag on OpenAstro project list tag if plugin's code was already implemented? (I do understand that some of astropy.utils and astropy.test.helpers needs to be re-implemented for separating out the modules.)

@pllim

pllim commented Mar 25, 2017

Copy link
Copy Markdown
Member

@mohanagr , the hard part is disentangling dependency and making it a viable independent package. If you find it easy, then great. Or if you find it too boring, then you are free to pick a different GSoC project to apply for.

@mohanagr

Copy link
Copy Markdown
Contributor

@pllim As a matter of fact I'm planning to submit for the splitting project! I have been looking into how astropy is structured and the test suites. I think there will be a lot to learn about packaging projects and making them work across different versions.

@mohanagr

Copy link
Copy Markdown
Contributor

@Cadair In the new standalone, are we to provide tests.helper functionality like custom warnings, handling deprecations (as exceptions), handling unicode guidelines etc. too? I mean features which are Astropy specific?
I mean do we single out functions/classes from astropy.tests.helpers and astropy.utils that the plugin code explicitly depends on or implement the whole thing?

@pllim

pllim commented Mar 27, 2017

Copy link
Copy Markdown
Member

@mohanagr , that is exactly the problem that I hope the GSoC project can solve. 😅

@mohanagr

mohanagr commented Mar 28, 2017 •

Copy link
Copy Markdown
Contributor

@pllim @Cadair Currently there is also this problem of running all plugin code from conftest.py itself. This implies I can't use --doctest-rst option if I run from let's say astropy but only from astropy/astropy and child directories. Separating out things will resolve this too.

This behavior was an issue with pytest.
Reference :
pytest-dev/pytest#906
In response a warning was added regarding the use of pytest.addoption -
pytest-dev/pytest@ccf7584

@Cadair

Cadair commented Mar 28, 2017

Copy link
Copy Markdown
Member Author

@mohanagr you mean registering the plugins in conftest rather than installing them and having them register as hooks?

@mohanagr

mohanagr commented Mar 28, 2017 •

Copy link
Copy Markdown
Contributor

@Cadair I meant that hook calls i.e. call to pytest_addoption from a plugin via pytest_plugins = ['plugin1'] might resolve the issue instead of all hook calls being in conftest.py itself.

Or perhaps declaring them in setup.py via entry_points.

This is what the comment by the maintainer reads:

If you change your conftest file into a plugin, it should work consistently no matter where you call py.test from, or what you pass on the command-line or perhaps via entry_points in setup.py.

It is unfortunate (but understandable) that there's this gotcha when working with pytest_addoption and conftest files, because conftest initialization being lazy as it is now can lead to surprising errors. Perhaps a note to pytest_addoption discouraging its use from conftest files would at least warn users of these pitfall?

Also, can you tell me what did you mean by installing plugins? I mean if they are there in the code itself.

Edit : Haven't tried it for this P.R. I was talking about the original code. You have already registered the plugins in pytest_plugins. I don't understand his statement about changing conftest file to a plugin.

@mohanagr

Copy link
Copy Markdown
Contributor

I was wrong above. The current way of specifying plugins in a file via pytest_plugins= produces the same thing (Tried changes in this PR). Declaring entry_point for plugins might be an option. @Cadair If you can tell me what the maintainer meant by changing conftest file to a plugin I might make some headway.

@bsipocz

bsipocz commented Mar 28, 2017

Copy link
Copy Markdown
Member

Also, can you tell me what did you mean by installing plugins? I mean if they are there in the code itself.

@mohanagr - you may want to check out other pytest plugins for the infrastructure and how-to (e.g. pytest-mpl, pytest-cov, etc). As it was said above one of the idea for the gsoc project was to factor out all the additions we have (compared to pure pytest) into an independent plugin. That means that it needs to be installed, and we don't have it any more in astropy core (pending a deprecation period of course).

@mohanagr

mohanagr commented Mar 28, 2017 •

Copy link
Copy Markdown
Contributor

@bsipocz Oh all right. Until now I was assuming there'd be separate multiple plugins. Hence didn't understand why would one do pip install pytest-plugin1,2,3 multiple times instead of just cloning and using them.

@bsipocz

bsipocz commented Mar 28, 2017

Copy link
Copy Markdown
Member

@mohanagr - Users don't clone anything, but install released versions.

@mohanagr

Copy link
Copy Markdown
Contributor

What if users are developers? 😃

@bsipocz

bsipocz commented Mar 28, 2017

Copy link
Copy Markdown
Member

You don't need to worry about that subset. Anyway cloning and using is not the preferred way for developers either when the aim is to build a stable package rather than hacking.

@pllim

pllim commented Mar 28, 2017

Copy link
Copy Markdown
Member

I think we are getting a bit too far off topic here. Questions related to the GSoC project should be discussed outside of this PR thread. As far as this PR is concerned, if you would like to take over, it is just simply splitting the current stuff into different modules, not a separate installable package.

@mohanagr

Copy link
Copy Markdown
Contributor

@pllim I understand. I couldn't find a way to reach you apart from GH comments!

@MSeifert04

Copy link
Copy Markdown
Contributor

There is a developer mailing list https://groups.google.com/forum/#!forum/astropy-dev

@bsipocz

bsipocz commented May 23, 2017

Copy link
Copy Markdown
Member

@Cadair - Any chance you have time to make this work for v2.0 (ff in 4 weeks time). I only ask as it would be a good one for deprecating, and 3.0 is to remove things.

@bsipocz

bsipocz commented Jun 12, 2017

Copy link
Copy Markdown
Member

@Cadair - pinging you again, whether we need to remilestone this or you can make some progress with it to be merged this week?

@Cadair

Cadair commented Jun 14, 2017

Copy link
Copy Markdown
Member Author

I will not be able to get to this before the freeze :(

@bsipocz

bsipocz commented Jul 21, 2017

Copy link
Copy Markdown
Member

Superseded by #6384.

@bsipocz bsipocz closed this Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants