Skip to content

Commit 0dd4236

Browse files
committed
use a fixture instead of a funcarg
1 parent 45d5bda commit 0dd4236

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎tests/test_ecodes.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from evdev import ecodes
44

5+
56
prefixes = 'KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF'
67

78
def to_tuples(l):

‎tests/test_uinput.py‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# encoding: utf-8
22

33
from select import select
4-
from pytest import raises
4+
from pytest import raises, fixture
55

66
from evdev import uinput, ecodes, events, device, util
77

88

9+
#-----------------------------------------------------------------------------
910
uinput_options = {
1011
'name' : 'test-py-evdev-uinput',
1112
'bustype' : ecodes.BUS_USB,
@@ -14,21 +15,21 @@
1415
'version' : 0x3300,
1516
}
1617

17-
18-
def pytest_funcarg__c(request):
18+
@fixture
19+
def c():
1920
return uinput_options.copy()
2021

21-
2222
def device_exists(bustype, vendor, product, version):
23-
match = 'I: Bus=%04hx Vendor=%04hx Product=%04hx Version=%04hx' % \
24-
(bustype, vendor, product, version)
23+
match = 'I: Bus=%04hx Vendor=%04hx Product=%04hx Version=%04hx'
24+
match = match % (bustype, vendor, product, version)
2525

2626
for line in open('/proc/bus/input/devices'):
27-
if line.strip() == match: return True
27+
if line.strip() == match:
28+
return True
2829

2930
return False
3031

31-
32+
#-----------------------------------------------------------------------------
3233
def test_open(c):
3334
ui = uinput.UInput(**c)
3435
args = (c['bustype'], c['vendor'], c['product'], c['version'])
@@ -59,15 +60,16 @@ def test_enable_events(c):
5960
def test_abs_values(c):
6061
e = ecodes
6162
c['events'] = {
62-
e.EV_KEY : [e.KEY_A, e.KEY_B],
63-
e.EV_ABS : [(e.ABS_X, (0, 255, 0, 0)),
64-
(e.ABS_Y, device.AbsInfo(0, 255, 5, 10, 0, 0))],
63+
e.EV_KEY: [e.KEY_A, e.KEY_B],
64+
e.EV_ABS: [(e.ABS_X, (0, 255, 0, 0)),
65+
(e.ABS_Y, device.AbsInfo(0, 255, 5, 10, 0, 0))],
6566
}
6667

6768
with uinput.UInput(**c) as ui:
6869
c = ui.capabilities()
6970
abs = device.AbsInfo(value=0, min=0, max=255, fuzz=0, flat=0, resolution=0)
7071
assert c[e.EV_ABS][0] == (0, abs)
72+
7173
abs = device.AbsInfo(value=0, min=0, max=255, fuzz=5, flat=10, resolution=0)
7274
assert c[e.EV_ABS][1] == (1, abs)
7375

0 commit comments

Comments
 (0)