Bug 2161702 - Provide a way for %pytest to not set PYTEST_XDIST_AUTO_NUM_WORKERS?
Summary: Provide a way for %pytest to not set PYTEST_XDIST_AUTO_NUM_WORKERS?
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-rpm-macros
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2161636
TreeView+ depends on / blocked
 
Reported: 2023-01-17 16:33 UTC by Scott Talbert
Modified: 2024-04-10 12:20 UTC (History)
7 users (show)

Fixed In Version: python-rpm-macros-3.12-7.fc40
Clone Of:
Environment:
Last Closed: 2024-04-10 12:20:39 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Scott Talbert 2023-01-17 16:33:34 UTC
Unfortunately, setting the PYTEST_XDIST_AUTO_NUM_WORKERS environment variable when running pytest-xdist's tests breaks the tests because the tests try to exercise all the different ways of configuring the number of workers and setting the env var interferes with this.

Would it be reasonable to provide some sort of way to disable setting of this env var?  If not, I can just not use %pytest in pytest-xdist.

Thanks.

Comment 1 Miro Hrončok 2023-01-17 16:53:20 UTC
We set other environment variables like this:

  PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"

Would doing this serve your needs?

  PYTEST_XDIST_AUTO_NUM_WORKERS="${PYTEST_XDIST_AUTO_NUM_WORKERS:-%{_smp_build_ncpus}}"

That way, you could export PYTEST_XDIST_AUTO_NUM_WORKERS= (nothing) which should be enough to ignore it:

https://github.com/pytest-dev/pytest-xdist/blob/v3.1.0/src/xdist/plugin.py#L16-L17


Such addition might be useful to others, as this will be possible:

  PYTEST_XDIST_AUTO_NUM_WORKERS=5 %pytest

Without %pytest overriding it back.


That said, we should probably fix pytest-xdist own test suite to work even when PYTEST_XDIST_AUTO_NUM_WORKERS is set from the outside. I'll take a look.

Comment 2 Miro Hrončok 2023-01-17 17:04:44 UTC
> That said, we should probably fix pytest-xdist own test suite to work even when PYTEST_XDIST_AUTO_NUM_WORKERS is set from the outside. I'll take a look.

Followed up in bz2161636.

Comment 3 Scott Talbert 2023-01-18 00:16:48 UTC
(In reply to Miro Hrončok from comment #1)
> We set other environment variables like this:
> 
>  
> PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:
> %{buildroot}%{python3_sitelib}}"
> 
> Would doing this serve your needs?
> 
>  
> PYTEST_XDIST_AUTO_NUM_WORKERS="${PYTEST_XDIST_AUTO_NUM_WORKERS:-
> %{_smp_build_ncpus}}"
> 
> That way, you could export PYTEST_XDIST_AUTO_NUM_WORKERS= (nothing) which
> should be enough to ignore it:
> 
> https://github.com/pytest-dev/pytest-xdist/blob/v3.1.0/src/xdist/plugin.
> py#L16-L17
> 
> 
> Such addition might be useful to others, as this will be possible:
> 
>   PYTEST_XDIST_AUTO_NUM_WORKERS=5 %pytest
> 
> Without %pytest overriding it back.
> 
> 
> That said, we should probably fix pytest-xdist own test suite to work even
> when PYTEST_XDIST_AUTO_NUM_WORKERS is set from the outside. I'll take a look.

Yes, this sounds great, but obviously a very low priority, especially in light of the other fix you did.

Comment 4 Miro Hrončok 2023-01-18 15:39:57 UTC
This works:


$ PYTEST_XDIST_AUTO_NUM_WORKERS=5
$ echo ${PYTEST_XDIST_AUTO_NUM_WORKERS:-3}
5

It is however impossible to opt-out completely by setting to an empty value:

$ PYTEST_XDIST_AUTO_NUM_WORKERS=
$ echo ${PYTEST_XDIST_AUTO_NUM_WORKERS:-3}
3


I don't know if that's possible in Shell. But OTOH I don't think many packages would ned that.

Comment 6 Ben Cotton 2023-02-07 15:13:26 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.


Note You need to log in before you can comment on or make changes to this bug.