A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/8075fe199b0569428cebaf213663bdd1ca40d792 below:

fix requires_OS_version() class decorator (GH-20942)… · python/cpython@8075fe1 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+21

-19

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+21

-19

lines changed Original file line number Diff line number Diff line change

@@ -586,25 +586,25 @@ def _requires_unix_version(sysname, min_version):

586 586

For example, @_requires_unix_version('FreeBSD', (7, 2)) raises SkipTest if

587 587

the FreeBSD version is less than 7.2.

588 588

"""

589 -

def decorator(func):

590 -

@functools.wraps(func)

591 -

def wrapper(*args, **kw):

592 -

if platform.system() == sysname:

593 -

version_txt = platform.release().split('-', 1)[0]

594 -

try:

595 -

version = tuple(map(int, version_txt.split('.')))

596 -

except ValueError:

597 -

pass

598 -

else:

599 -

if version < min_version:

600 -

min_version_txt = '.'.join(map(str, min_version))

601 -

raise unittest.SkipTest(

602 -

"%s version %s or higher required, not %s"

603 -

% (sysname, min_version_txt, version_txt))

604 -

return func(*args, **kw)

605 -

wrapper.min_version = min_version

606 -

return wrapper

607 -

return decorator

589 +

import platform

590 +

min_version_txt = '.'.join(map(str, min_version))

591 +

version_txt = platform.release().split('-', 1)[0]

592 +

if platform.system() == sysname:

593 +

try:

594 +

version = tuple(map(int, version_txt.split('.')))

595 +

except ValueError:

596 +

skip = False

597 +

else:

598 +

skip = version < min_version

599 +

else:

600 +

skip = False

601 + 602 +

return unittest.skipIf(

603 +

skip,

604 +

f"{sysname} version {min_version_txt} or higher required, not "

605 +

f"{version_txt}"

606 +

)

607 + 608 608 609 609

def requires_freebsd_version(*min_version):

610 610

"""Decorator raising SkipTest if the OS is FreeBSD and the FreeBSD version is

Original file line number Diff line number Diff line change

@@ -0,0 +1,2 @@

1 +

Fix use of ``support.require_{linux|mac|freebsd}_version()`` decorators as

2 +

class decorator.

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4