@@ -77,22 +77,19 @@ def _get_first_controller(self):
7777 return controller .Controller (i )
7878
7979 def test_construction (self ):
80- c = self ._get_first_controller ()
81- if c :
80+ if c := self ._get_first_controller ():
8281 self .assertIsInstance (c , controller .Controller )
8382 else :
8483 self .skipTest ("No controller connected" )
8584
8685 def test__auto_init (self ):
87- c = self ._get_first_controller ()
88- if c :
86+ if c := self ._get_first_controller ():
8987 self .assertTrue (c .get_init ())
9088 else :
9189 self .skipTest ("No controller connected" )
9290
9391 def test_get_init (self ):
94- c = self ._get_first_controller ()
95- if c :
92+ if c := self ._get_first_controller ():
9693 self .assertTrue (c .get_init ())
9794 c .quit ()
9895 self .assertFalse (c .get_init ())
@@ -111,25 +108,22 @@ def test_from_joystick(self):
111108 self .assertIsInstance (c , controller .Controller )
112109
113110 def test_as_joystick (self ):
114- c = self ._get_first_controller ()
115- if c :
111+ if c := self ._get_first_controller ():
116112 joy = c .as_joystick ()
117113 self .assertIsInstance (joy , type (pygame .joystick .Joystick (0 )))
118114 else :
119115 self .skipTest ("No controller connected" )
120116
121117 def test_get_mapping (self ):
122- c = self ._get_first_controller ()
123- if c :
118+ if c := self ._get_first_controller ():
124119 mapping = c .get_mapping ()
125120 self .assertIsInstance (mapping , dict )
126121 self .assertIsNotNone (mapping ["a" ])
127122 else :
128123 self .skipTest ("No controller connected" )
129124
130125 def test_set_mapping (self ):
131- c = self ._get_first_controller ()
132- if c :
126+ if c := self ._get_first_controller ():
133127 mapping = c .get_mapping ()
134128 mapping ["a" ] = "b3"
135129 mapping ["y" ] = "b0"
0 commit comments