File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Lib/test/test_importlib/metadata Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import functools
2+ import os
3+ import random
4+ import unittest
5+
6+
7+ skip_first = bool (random .randint (0 , 1 ))
8+
9+
10+ @functools .cache
11+ def skip_one_or_the_other (func , seen = {}):
12+ """
13+ #132947 revealed that after applying some otherwise stable
14+ changes, only on some buildbot runners, the tests will fail with
15+ ResourceWarnings, but only if both of two tests are run.
16+
17+ This decorator causes stochastically one of two functions to be
18+ skipped, so they're both run normally, but only one is run when
19+ under a buildbot.
20+ """
21+ is_buildbot = 'BUILDBOT_RUN' not in os .environ
22+
23+ skip_second = not skip_first
24+
25+ if len (seen ) > 2 :
26+ raise ValueError ("Intended for no more than two functions." )
27+
28+ skip_this = (skip_second if seen else skip_first ) and is_buildbot
29+ skipper = unittest .skip ("Causes Resource Warnings (python/cpython#132947)" )
30+ wrapper = skipper if skip_this else lambda x : x
31+ return wrapper (func )
Original file line number Diff line number Diff line change 2222)
2323
2424from . import fixtures
25+ from . import _issue132947
2526from ._path import Symlink
2627
2728
@@ -157,6 +158,7 @@ def test_valid_dists_preferred(self):
157158 dist = Distribution .from_name ('foo' )
158159 assert dist .version == "1.0"
159160
161+ @_issue132947 .skip_one_or_the_other
160162 def test_missing_metadata (self ):
161163 """
162164 Dists with a missing metadata file should return None.
@@ -357,6 +359,7 @@ def test_packages_distributions_example(self):
357359 self ._fixture_on_path ('example-21.12-py3-none-any.whl' )
358360 assert packages_distributions ()['example' ] == ['example' ]
359361
362+ @_issue132947 .skip_one_or_the_other
360363 def test_packages_distributions_example2 (self ):
361364 """
362365 Test packages_distributions on a wheel built
You can’t perform that action at this time.
0 commit comments