mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
dev-python/pyudev: revbump, fix tests, py310
Copyright: Sony Interactive Entertainment Inc. Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
This commit is contained in:
committed by
Patrick McLean
parent
5321f8cd17
commit
7f94bc4ee4
142
dev-python/pyudev/files/pyudev-0.22-fix-hypothesis.patch
Normal file
142
dev-python/pyudev/files/pyudev-0.22-fix-hypothesis.patch
Normal file
@@ -0,0 +1,142 @@
|
||||
commit c27845613527091201160a578eacd36a538dea81
|
||||
Author: mulhern <amulhern@redhat.com>
|
||||
Date: Thu May 3 09:12:26 2018 -0400
|
||||
|
||||
Eliminate Hypothesis warnings
|
||||
|
||||
* Reduce the max_examples value so that tests don't trigger Hypothesis's
|
||||
deadline check.
|
||||
* Turn generators into lists, so that Hypothesis can consistently repeat the
|
||||
tests (presumably for shrinking).
|
||||
|
||||
Signed-off-by: mulhern <amulhern@redhat.com>
|
||||
|
||||
diff --git a/tests/_constants.py b/tests/_constants.py
|
||||
index fb85f30..7003a5c 100644
|
||||
--- a/tests/_constants.py
|
||||
+++ b/tests/_constants.py
|
||||
@@ -53,7 +53,7 @@ def _check_device(device):
|
||||
return False
|
||||
|
||||
|
||||
-_DEVICE_DATA = udev.DeviceDatabase.db()
|
||||
+_DEVICE_DATA = [d for d in udev.DeviceDatabase.db()]
|
||||
_DEVICES = [Devices.from_path(_CONTEXT, d.device_path) for d in _DEVICE_DATA]
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ def device_strategy(require_existing=True, filter_func=lambda x: True):
|
||||
:type filter_func: Device -> bool
|
||||
"""
|
||||
strategy = strategies.sampled_from(
|
||||
- x for x in _CONTEXT.list_devices() if filter_func(x))
|
||||
+ [x for x in _CONTEXT.list_devices() if filter_func(x)])
|
||||
|
||||
if require_existing:
|
||||
strategy = strategy.filter(_check_device)
|
||||
@@ -89,7 +89,7 @@ def device_strategy(require_existing=True, filter_func=lambda x: True):
|
||||
_SYSNAME_STRATEGY = device_strategy().map(lambda x: x.sys_name)
|
||||
|
||||
_PROPERTY_STRATEGY = device_strategy().flatmap(
|
||||
- lambda d: strategies.sampled_from(d.properties.items()))
|
||||
+ lambda d: strategies.sampled_from([p for p in d.properties.items()]))
|
||||
|
||||
_MATCH_PROPERTY_STRATEGY = \
|
||||
_PROPERTY_STRATEGY.filter(lambda p: p[0][-4:] != "_ENC")
|
||||
@@ -104,7 +104,7 @@ def device_strategy(require_existing=True, filter_func=lambda x: True):
|
||||
# an attribute key and value pair
|
||||
_ATTRIBUTE_STRATEGY = \
|
||||
_ATTRIBUTES_STRATEGY.flatmap(
|
||||
- lambda attrs: strategies.sampled_from(attrs.available_attributes).map(
|
||||
+ lambda attrs: strategies.sampled_from([a for a in attrs.available_attributes]).map(
|
||||
lambda key: (key, attrs.get(key))
|
||||
)
|
||||
)
|
||||
@@ -119,11 +119,11 @@ def device_strategy(require_existing=True, filter_func=lambda x: True):
|
||||
)
|
||||
|
||||
# the tags object for a given device
|
||||
-_TAGS_STRATEGY = device_strategy().map(lambda d: d.tags)
|
||||
+_TAGS_STRATEGY = device_strategy().map(lambda d: [t for t in d.tags])
|
||||
|
||||
# an arbitrary tag belonging to a given device
|
||||
_TAG_STRATEGY = \
|
||||
- _TAGS_STRATEGY.filter(lambda t: sum(1 for _ in t) != 0).flatmap(
|
||||
+ _TAGS_STRATEGY.filter(lambda t: t != []).flatmap(
|
||||
strategies.sampled_from
|
||||
)
|
||||
|
||||
diff --git a/tests/_device_tests/_device_tests.py b/tests/_device_tests/_device_tests.py
|
||||
index 0350a10..3e8710a 100644
|
||||
--- a/tests/_device_tests/_device_tests.py
|
||||
+++ b/tests/_device_tests/_device_tests.py
|
||||
@@ -352,7 +352,7 @@ def test_key_subset(self, a_context, device_datum):
|
||||
frozenset(device.properties.keys())
|
||||
|
||||
@given(_CONTEXT_STRATEGY, strategies.sampled_from(_DEVICE_DATA))
|
||||
- @settings(max_examples=100)
|
||||
+ @settings(max_examples=1)
|
||||
def test_getitem(self, a_context, device_datum):
|
||||
device = Devices.from_path(a_context, device_datum.device_path)
|
||||
for prop in device_datum.properties:
|
||||
diff --git a/tests/test_discover.py b/tests/test_discover.py
|
||||
index e623435..3cf9e8c 100644
|
||||
--- a/tests/test_discover.py
|
||||
+++ b/tests/test_discover.py
|
||||
@@ -46,7 +46,7 @@
|
||||
from hypothesis import strategies
|
||||
|
||||
_CONTEXT = pyudev.Context()
|
||||
-_DEVICES = _CONTEXT.list_devices()
|
||||
+_DEVICES = [d for d in _CONTEXT.list_devices()]
|
||||
|
||||
NUM_TESTS = 5
|
||||
|
||||
diff --git a/tests/test_enumerate.py b/tests/test_enumerate.py
|
||||
index c9c6a67..a9662bd 100644
|
||||
--- a/tests/test_enumerate.py
|
||||
+++ b/tests/test_enumerate.py
|
||||
@@ -90,7 +90,7 @@ class TestEnumerator(object):
|
||||
|
||||
@failed_health_check_wrapper
|
||||
@given(_CONTEXT_STRATEGY, _SUBSYSTEM_STRATEGY)
|
||||
- @settings(max_examples=50)
|
||||
+ @settings(max_examples=10)
|
||||
def test_match_subsystem(self, context, subsystem):
|
||||
"""
|
||||
Subsystem match matches devices w/ correct subsystem.
|
||||
@@ -102,7 +102,7 @@ def test_match_subsystem(self, context, subsystem):
|
||||
|
||||
@failed_health_check_wrapper
|
||||
@given(_CONTEXT_STRATEGY, _SUBSYSTEM_STRATEGY)
|
||||
- @settings(max_examples=5)
|
||||
+ @settings(max_examples=1)
|
||||
def test_match_subsystem_nomatch(self, context, subsystem):
|
||||
"""
|
||||
Subsystem no match gets no subsystem with subsystem.
|
||||
@@ -126,7 +126,7 @@ def test_match_subsystem_nomatch_unfulfillable(self, context, subsystem):
|
||||
|
||||
@failed_health_check_wrapper
|
||||
@given(_CONTEXT_STRATEGY, _SUBSYSTEM_STRATEGY)
|
||||
- @settings(max_examples=5)
|
||||
+ @settings(max_examples=1)
|
||||
def test_match_subsystem_nomatch_complete(self, context, subsystem):
|
||||
"""
|
||||
Test that w/ respect to the universe of devices returned by
|
||||
@@ -155,7 +155,7 @@ def test_match_sys_name(self, context, sysname):
|
||||
|
||||
@failed_health_check_wrapper
|
||||
@given(_CONTEXT_STRATEGY, _MATCH_PROPERTY_STRATEGY)
|
||||
- @settings(max_examples=50)
|
||||
+ @settings(max_examples=25)
|
||||
def test_match_property_string(self, context, pair):
|
||||
"""
|
||||
Match property only gets devices with that property.
|
||||
@@ -243,7 +243,7 @@ class TestEnumeratorMatchCombinations(object):
|
||||
min_size=2,
|
||||
max_size=3,
|
||||
unique_by=lambda p: p[0]))
|
||||
- @settings(max_examples=20)
|
||||
+ @settings(max_examples=2)
|
||||
def test_combined_property_matches(self, context, ppairs):
|
||||
"""
|
||||
Test for behaviour as observed in #1
|
||||
56
dev-python/pyudev/files/pyudev-0.22-pytest-4.patch
Normal file
56
dev-python/pyudev/files/pyudev-0.22-pytest-4.patch
Normal file
@@ -0,0 +1,56 @@
|
||||
commit f962902b8298d97622b97693aba90032e5b9d2ec
|
||||
Author: FFY00 <filipe.lains@gmail.com>
|
||||
Date: Fri May 24 19:08:41 2019 +0100
|
||||
|
||||
tests: fix tests for pytest 4.0
|
||||
|
||||
diff --git a/tests/plugins/mock_libudev.py b/tests/plugins/mock_libudev.py
|
||||
index aefeb31..0bde07b 100644
|
||||
--- a/tests/plugins/mock_libudev.py
|
||||
+++ b/tests/plugins/mock_libudev.py
|
||||
@@ -32,6 +32,7 @@
|
||||
from contextlib import contextmanager
|
||||
from collections import namedtuple
|
||||
|
||||
+import pytest
|
||||
import mock
|
||||
|
||||
Node = namedtuple('Node', 'name value next')
|
||||
@@ -93,5 +94,6 @@ def libudev_list(libudev, function, items):
|
||||
EXPOSED_FUNCTIONS = [libudev_list]
|
||||
|
||||
|
||||
-def pytest_namespace():
|
||||
- return dict((f.__name__, f) for f in EXPOSED_FUNCTIONS)
|
||||
+def pytest_configure():
|
||||
+ for f in EXPOSED_FUNCTIONS:
|
||||
+ setattr(pytest, f.__name__, f)
|
||||
diff --git a/tests/plugins/privileged.py b/tests/plugins/privileged.py
|
||||
index 92328b9..c636980 100644
|
||||
--- a/tests/plugins/privileged.py
|
||||
+++ b/tests/plugins/privileged.py
|
||||
@@ -71,5 +71,6 @@ def unload_dummy():
|
||||
EXPOSED_FUNCTIONS = [load_dummy, unload_dummy]
|
||||
|
||||
|
||||
-def pytest_namespace():
|
||||
- return dict((f.__name__, f) for f in EXPOSED_FUNCTIONS)
|
||||
+def pytest_configure():
|
||||
+ for f in EXPOSED_FUNCTIONS:
|
||||
+ setattr(pytest, f.__name__, f)
|
||||
diff --git a/tests/plugins/travis.py b/tests/plugins/travis.py
|
||||
index 46466c2..15a780e 100644
|
||||
--- a/tests/plugins/travis.py
|
||||
+++ b/tests/plugins/travis.py
|
||||
@@ -38,8 +38,9 @@ def is_on_travis_ci():
|
||||
EXPOSED_FUNCTIONS = [is_on_travis_ci]
|
||||
|
||||
|
||||
-def pytest_namespace():
|
||||
- return dict((f.__name__, f) for f in EXPOSED_FUNCTIONS)
|
||||
+def pytest_configure():
|
||||
+ for f in EXPOSED_FUNCTIONS:
|
||||
+ setattr(pytest, f.__name__, f)
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
126
dev-python/pyudev/files/pyudev-0.22-remove-flaky-tests.patch
Normal file
126
dev-python/pyudev/files/pyudev-0.22-remove-flaky-tests.patch
Normal file
@@ -0,0 +1,126 @@
|
||||
commit a35c394f7f4eb714eeaab1b8ed7977f822e29fa9
|
||||
Author: mulhern <amulhern@redhat.com>
|
||||
Date: Wed May 2 15:50:45 2018 -0400
|
||||
|
||||
Get rid of all test_match_attribute_* methods
|
||||
|
||||
These tests are rendered flaky by the volatility of attribute values.
|
||||
|
||||
Signed-off-by: mulhern <amulhern@redhat.com>
|
||||
|
||||
diff --git a/tests/test_enumerate.py b/tests/test_enumerate.py
|
||||
index f054799..c9c6a67 100644
|
||||
--- a/tests/test_enumerate.py
|
||||
+++ b/tests/test_enumerate.py
|
||||
@@ -200,77 +200,6 @@ def test_match_property_bool(self, context, pair):
|
||||
for device in devices
|
||||
)
|
||||
|
||||
- @failed_health_check_wrapper
|
||||
- @given(_CONTEXT_STRATEGY, _ATTRIBUTE_STRATEGY)
|
||||
- @settings(max_examples=50)
|
||||
- def test_match_attribute_nomatch_unfulfillable(self, context, pair):
|
||||
- """
|
||||
- Match and no match for a key/value gives empty set.
|
||||
- """
|
||||
- key, value = pair
|
||||
- devices = context.list_devices()
|
||||
- devices.match_attribute(key, value)
|
||||
- devices.match_attribute(key, value, nomatch=True)
|
||||
- assert not list(devices)
|
||||
-
|
||||
- @failed_health_check_wrapper
|
||||
- @given(_CONTEXT_STRATEGY, _ATTRIBUTE_STRATEGY)
|
||||
- @settings(max_examples=50)
|
||||
- def test_match_attribute_nomatch_complete(self, context, pair):
|
||||
- """
|
||||
- Test that w/ respect to the universe of devices returned by
|
||||
- list_devices() a match and its inverse are complements of each other.
|
||||
- """
|
||||
- key, value = pair
|
||||
- m_devices = frozenset(context.list_devices().match_attribute(
|
||||
- key, value))
|
||||
- nm_devices = frozenset(context.list_devices().match_attribute(
|
||||
- key, value, nomatch=True))
|
||||
- _test_intersection_and_union(context, m_devices, nm_devices)
|
||||
-
|
||||
- @failed_health_check_wrapper
|
||||
- @given(_CONTEXT_STRATEGY, _ATTRIBUTE_STRATEGY)
|
||||
- @settings(max_examples=50)
|
||||
- def test_match_attribute_string(self, context, pair):
|
||||
- """
|
||||
- Test that matching attribute as string works.
|
||||
- """
|
||||
- key, value = pair
|
||||
- devices = context.list_devices().match_attribute(key, value)
|
||||
- assert all(device.attributes.get(key) == value for device in devices)
|
||||
-
|
||||
- @failed_health_check_wrapper
|
||||
- @given(_CONTEXT_STRATEGY,
|
||||
- _ATTRIBUTE_STRATEGY.filter(lambda x: _is_int(x[1])))
|
||||
- @settings(max_examples=50)
|
||||
- def test_match_attribute_int(self, context, pair):
|
||||
- """
|
||||
- Test matching integer attribute.
|
||||
- """
|
||||
- key, value = pair
|
||||
- int_value = int(value)
|
||||
- devices = context.list_devices().match_attribute(key, int_value)
|
||||
- for device in devices:
|
||||
- attributes = device.attributes
|
||||
- assert attributes.get(key) == value
|
||||
- assert device.attributes.asint(key) == int_value
|
||||
-
|
||||
- @failed_health_check_wrapper
|
||||
- @given(_CONTEXT_STRATEGY,
|
||||
- _ATTRIBUTE_STRATEGY.filter(lambda x: _is_bool(x[1])))
|
||||
- @settings(max_examples=50)
|
||||
- def test_match_attribute_bool(self, context, pair):
|
||||
- """
|
||||
- Test matching boolean attribute.
|
||||
- """
|
||||
- key, value = pair
|
||||
- bool_value = True if int(value) == 1 else False
|
||||
- devices = context.list_devices().match_attribute(key, bool_value)
|
||||
- for device in devices:
|
||||
- attributes = device.attributes
|
||||
- assert attributes.get(key) == value
|
||||
- assert attributes.asbool(key) == bool_value
|
||||
-
|
||||
@_UDEV_TEST(154, "test_match_tag")
|
||||
@failed_health_check_wrapper
|
||||
@given(_CONTEXT_STRATEGY, _TAG_STRATEGY)
|
||||
@@ -335,33 +264,6 @@ def test_combined_property_matches(self, context, ppairs):
|
||||
)
|
||||
)
|
||||
|
||||
- @given(_CONTEXT_STRATEGY,
|
||||
- strategies.lists(
|
||||
- elements=_ATTRIBUTE_STRATEGY,
|
||||
- min_size=2,
|
||||
- max_size=3,
|
||||
- unique_by=lambda p: p[0]))
|
||||
- @settings(max_examples=20)
|
||||
- def test_combined_attribute_matches(self, context, apairs):
|
||||
- """
|
||||
- Test for conjunction of attributes.
|
||||
-
|
||||
- If matching multiple attributes, then the result is the intersection of
|
||||
- the matching sets, i.e., the resulting filter is a conjunction.
|
||||
- """
|
||||
- enumeration = context.list_devices()
|
||||
-
|
||||
- for key, value in apairs:
|
||||
- enumeration.match_attribute(key, value)
|
||||
-
|
||||
- _test_direct_and_complement(
|
||||
- context,
|
||||
- frozenset(enumeration),
|
||||
- lambda d: all(
|
||||
- d.attributes.get(key) == value for key, value in apairs
|
||||
- )
|
||||
- )
|
||||
-
|
||||
@given(_CONTEXT_STRATEGY,
|
||||
strategies.lists(
|
||||
elements=_MATCH_PROPERTY_STRATEGY,
|
||||
53
dev-python/pyudev/pyudev-0.22.0-r1.ebuild
Normal file
53
dev-python/pyudev/pyudev-0.22.0-r1.ebuild
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright 1999-2021 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
PYTHON_COMPAT=( python3_{7..10} )
|
||||
|
||||
inherit distutils-r1
|
||||
|
||||
DESCRIPTION="Python binding to libudev"
|
||||
HOMEPAGE="https://pyudev.readthedocs.io/en/latest/ https://github.com/pyudev/pyudev"
|
||||
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
|
||||
|
||||
LICENSE="LGPL-2.1"
|
||||
SLOT="0"
|
||||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
|
||||
IUSE="qt5"
|
||||
|
||||
RDEPEND="
|
||||
dev-python/six[${PYTHON_USEDEP}]
|
||||
virtual/udev
|
||||
qt5? ( dev-python/PyQt5[${PYTHON_USEDEP}] )
|
||||
"
|
||||
DEPEND="${RDEPEND}
|
||||
dev-python/setuptools[${PYTHON_USEDEP}]
|
||||
test? (
|
||||
dev-python/docutils[${PYTHON_USEDEP}]
|
||||
dev-python/hypothesis[${PYTHON_USEDEP}]
|
||||
dev-python/mock[${PYTHON_USEDEP}]
|
||||
)"
|
||||
|
||||
DOCS=( CHANGES.rst README.rst )
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}/pyudev-0.22-pytest-4.patch"
|
||||
"${FILESDIR}/pyudev-0.22-remove-flaky-tests.patch"
|
||||
"${FILESDIR}/pyudev-0.22-fix-hypothesis.patch"
|
||||
)
|
||||
|
||||
distutils_enable_tests pytest
|
||||
|
||||
python_prepare_all() {
|
||||
if use test; then
|
||||
ewarn "If your PORTAGE_TMPDIR is longer in length then '/var/tmp/',"
|
||||
ewarn "change it to /var/tmp to ensure tests will pass."
|
||||
fi
|
||||
|
||||
# tests are known to pass then fail on alternate runs
|
||||
# tests: fix run_path
|
||||
sed -i -e "s|== \('/run/udev'\)|in (\1,'/dev/.udev')|g" \
|
||||
tests/test_core.py || die
|
||||
|
||||
distutils-r1_python_prepare_all
|
||||
}
|
||||
Reference in New Issue
Block a user