Fix lint errors to enable stricter PyLint rules
These fixes are needed to avoid errors after submitting https://codereview.webrtc.org/2737963003 BUG=webrtc:7303 NOTRY=True Review-Url: https://codereview.webrtc.org/2812273002 Cr-Commit-Position: refs/heads/master@{#17679}
This commit is contained in:
@ -13,28 +13,28 @@ from video_analysis import FindUsbPortForV4lDevices
|
||||
|
||||
|
||||
class RunVideoAnalysisTest(unittest.TestCase):
|
||||
def setGlobPath(self, path1, path2):
|
||||
def SetGlobPath(self, path1, path2):
|
||||
self.path1 = path1
|
||||
self.path2 = path2
|
||||
|
||||
def setUp(self):
|
||||
self.path1 = ''
|
||||
self.path2 = ''
|
||||
self.requestNbr = 1
|
||||
self.request_nbr = 1
|
||||
|
||||
def glob_mock(string):
|
||||
def GlobMock(string):
|
||||
# Eat incoming string.
|
||||
del string
|
||||
if self.requestNbr == 1:
|
||||
self.requestNbr += 1
|
||||
if self.request_nbr == 1:
|
||||
self.request_nbr += 1
|
||||
return self.path1
|
||||
else:
|
||||
self.requestNbr = 1
|
||||
self.request_nbr = 1
|
||||
return self.path2
|
||||
|
||||
# Override the glob function with our own that returns a string set by the
|
||||
# test.
|
||||
glob.glob = glob_mock
|
||||
glob.glob = GlobMock
|
||||
|
||||
# Verifies that the correct USB id is returned.
|
||||
def testFindUSBPortForV4lDevices(self):
|
||||
@ -42,7 +42,7 @@ class RunVideoAnalysisTest(unittest.TestCase):
|
||||
'video4linux/video0')
|
||||
short_path2 = ('/sys/bus/usb/devices/usb1/1-1/driver/4-3/4-3:1.0/'
|
||||
'video4linux/video1')
|
||||
self.setGlobPath(short_path1, short_path2)
|
||||
self.SetGlobPath(short_path1, short_path2)
|
||||
short_usb_ids = ['4-4', '4-3']
|
||||
self.assertEqual(FindUsbPortForV4lDevices('video0', 'video1'),
|
||||
short_usb_ids)
|
||||
@ -51,16 +51,16 @@ class RunVideoAnalysisTest(unittest.TestCase):
|
||||
'video4linux/video0')
|
||||
long_path2 = ('/sys/bus/usb/devices/usb1/1-1/driver/3-2/3-2.1:1.0/'
|
||||
'video4linux/video1')
|
||||
self.setGlobPath(long_path1, long_path2)
|
||||
self.SetGlobPath(long_path1, long_path2)
|
||||
long_usb_ids = ['3-3.1', '3-2.1']
|
||||
self.assertEqual(FindUsbPortForV4lDevices('video0', 'video1'), long_usb_ids)
|
||||
|
||||
|
||||
def testFindUSBPortForV4lDevicesNoDevice(self):
|
||||
noDeviceFound = ('')
|
||||
V4lDevice = ('/sys/bus/usb/devices/usb1/1-1/driver/3-2/3-2.1:1.0/'
|
||||
no_device_found = ('')
|
||||
v4l_device = ('/sys/bus/usb/devices/usb1/1-1/driver/3-2/3-2.1:1.0/'
|
||||
'video4linux/video1')
|
||||
self.setGlobPath(noDeviceFound, V4lDevice)
|
||||
self.SetGlobPath(no_device_found, v4l_device)
|
||||
empty_list = []
|
||||
self.assertEqual(FindUsbPortForV4lDevices('video0', 'video1'), empty_list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user