Re: Issues running pytest from within .pybuild

2020-05-18 Thread Christian Kastner
On 2020-05-18 01:30, Scott Kitterman wrote:
> On Sunday, May 17, 2020 6:26:11 PM EDT Christian Kastner wrote:
>> From the GitHub issue, it seems as if the current practice of testing
>> from within .pybuild is not supported by pytest, but I'm inclined to
>> believe that it is my approach that is flawed.
>>
>> [1] https://github.com/pytest-dev/pytest/issues/7223
> 
> I think this would only happen if sys.path had been extended to include the 
> main source directory.  You may need to cd to $SRCDIR/.pybuild/.../sklearn 
> before calling pytest or something may be inserting the source directory into 
> sys.path.

All of this is being delegated to pybuild, by calling it with the
--test-pytest option. It takes care of cd'ing to the build dir before
calling pytest. The only customization is using --pytest-args to pass
some additional options to exclude some tests.

Hence why I'm puzzled to see this.

Manually cd'ing into the directory and running pytest (to test whether
pybuild is doing something funny) doesn't help.

It really looks as if this is a pytest issue, but on the GitHub issue
linked above, the assessment was "It's a little weird to discover tests
from an ephemeral build dir". Seeing as doing this is the standard
practice for pybuild, I thought it best to check back here.

Christian



Re: Issues running pytest from within .pybuild

2020-05-17 Thread Scott Kitterman
On Sunday, May 17, 2020 6:26:11 PM EDT Christian Kastner wrote:
> In a recent version of src:scikit-learn, a workaround was added to
> resolve an ImportMismatchError regarding one of the conftest.py files
> used by pytest.
> 
> I hit a new instance of this while preparing a new upstream release, so
> I inquired [1] with pytest upstream as to why this could be happening.
> 
> Apparently, the error is caused by the .pybuild directory being located
> as a subfolder of the source directory. This leads to pytest finding two
> separate sklearn/conftest.py files
>   * $SRCDIR/sklearn/conftest.py
>   * $SRCDIR/.pybuild/.../sklearn/conftest.py)
> which triggers the ImportMisMatchError.
> 
> Now, I've only seen this happen with src:scikit-learn, and (oddly
> enough) only with 2 of 4 conftest.py files. The other two do not trigger
> the error, nor do other packages of mine which use pytest.
> 
> Has anyone seen something similar with their packages, or is anyone
> aware of any recipes that can be used to resolve the issue properly?
> 
> >From the GitHub issue, it seems as if the current practice of testing
> 
> from within .pybuild is not supported by pytest, but I'm inclined to
> believe that it is my approach that is flawed.
> 
> [1] https://github.com/pytest-dev/pytest/issues/7223
> 
> Christian

I think this would only happen if sys.path had been extended to include the 
main source directory.  You may need to cd to $SRCDIR/.pybuild/.../sklearn 
before calling pytest or something may be inserting the source directory into 
sys.path.

Scott K

signature.asc
Description: This is a digitally signed message part.


Issues running pytest from within .pybuild

2020-05-17 Thread Christian Kastner
In a recent version of src:scikit-learn, a workaround was added to
resolve an ImportMismatchError regarding one of the conftest.py files
used by pytest.

I hit a new instance of this while preparing a new upstream release, so
I inquired [1] with pytest upstream as to why this could be happening.

Apparently, the error is caused by the .pybuild directory being located
as a subfolder of the source directory. This leads to pytest finding two
separate sklearn/conftest.py files
  * $SRCDIR/sklearn/conftest.py
  * $SRCDIR/.pybuild/.../sklearn/conftest.py)
which triggers the ImportMisMatchError.

Now, I've only seen this happen with src:scikit-learn, and (oddly
enough) only with 2 of 4 conftest.py files. The other two do not trigger
the error, nor do other packages of mine which use pytest.

Has anyone seen something similar with their packages, or is anyone
aware of any recipes that can be used to resolve the issue properly?

>From the GitHub issue, it seems as if the current practice of testing
from within .pybuild is not supported by pytest, but I'm inclined to
believe that it is my approach that is flawed.

[1] https://github.com/pytest-dev/pytest/issues/7223

Christian