Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: webrtc/tools/py_event_log_analyzer/rtp_analyzer_test.py

Issue 2812273002: Fix lint errors to enable stricter PyLint rules (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/tools/py_event_log_analyzer/rtp_analyzer.py ('k') | webrtc/tools/video_analysis_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license 4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source 5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found 6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may 7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree. 8 # be found in the AUTHORS file in the root of the source tree.
9 9
10 """Run the tests with 10 """Run the tests with
11 11
12 python rtp_analyzer_test.py 12 python rtp_analyzer_test.py
13 or 13 or
14 python3 rtp_analyzer_test.py 14 python3 rtp_analyzer_test.py
15 """ 15 """
16 16
17 import collections 17 import collections
18 import unittest 18 import unittest
19 19
20 missing_numpy = False 20 MISSING_NUMPY = False # pylint: disable=invalid-name
21 try: 21 try:
22 import numpy 22 import numpy
23 import rtp_analyzer 23 import rtp_analyzer
24 except ImportError: 24 except ImportError:
25 missing_numpy = True 25 MISSING_NUMPY = True
26 26
27 FakePoint = collections.namedtuple("FakePoint", 27 FakePoint = collections.namedtuple("FakePoint",
28 ["real_send_time_ms", "absdelay"]) 28 ["real_send_time_ms", "absdelay"])
29 29
30 30
31 class TestDelay(unittest.TestCase): 31 class TestDelay(unittest.TestCase):
32 def assertMaskEqual(self, masked_array, data, mask): 32 def AssertMaskEqual(self, masked_array, data, mask):
33 self.assertEqual(list(masked_array.data), data) 33 self.assertEqual(list(masked_array.data), data)
34 34
35 if isinstance(masked_array.mask, numpy.bool_): 35 if isinstance(masked_array.mask, numpy.bool_):
36 array_mask = masked_array.mask 36 array_mask = masked_array.mask
37 else: 37 else:
38 array_mask = list(masked_array.mask) 38 array_mask = list(masked_array.mask)
39 self.assertEqual(array_mask, mask) 39 self.assertEqual(array_mask, mask)
40 40
41 def testCalculateDelaySimple(self): 41 def testCalculateDelaySimple(self):
42 points = [FakePoint(0, 0), FakePoint(1, 0)] 42 points = [FakePoint(0, 0), FakePoint(1, 0)]
43 mask = rtp_analyzer.calculate_delay(0, 1, 1, points) 43 mask = rtp_analyzer.CalculateDelay(0, 1, 1, points)
44 self.assertMaskEqual(mask, [0, 0], False) 44 self.AssertMaskEqual(mask, [0, 0], False)
45 45
46 def testCalculateDelayMissing(self): 46 def testCalculateDelayMissing(self):
47 points = [FakePoint(0, 0), FakePoint(2, 0)] 47 points = [FakePoint(0, 0), FakePoint(2, 0)]
48 mask = rtp_analyzer.calculate_delay(0, 2, 1, points) 48 mask = rtp_analyzer.CalculateDelay(0, 2, 1, points)
49 self.assertMaskEqual(mask, [0, -1, 0], [False, True, False]) 49 self.AssertMaskEqual(mask, [0, -1, 0], [False, True, False])
50 50
51 def testCalculateDelayBorders(self): 51 def testCalculateDelayBorders(self):
52 points = [FakePoint(0, 0), FakePoint(2, 0)] 52 points = [FakePoint(0, 0), FakePoint(2, 0)]
53 mask = rtp_analyzer.calculate_delay(0, 3, 2, points) 53 mask = rtp_analyzer.CalculateDelay(0, 3, 2, points)
54 self.assertMaskEqual(mask, [0, 0, -1], [False, False, True]) 54 self.AssertMaskEqual(mask, [0, 0, -1], [False, False, True])
55 55
56 56
57 if __name__ == "__main__": 57 if __name__ == "__main__":
58 if missing_numpy: 58 if MISSING_NUMPY:
59 # pylint: disable=superfluous-parens 59 print "Missing numpy, skipping test."
60 print("Missing numpy, skipping test.")
61 else: 60 else:
62 unittest.main() 61 unittest.main()
OLDNEW
« no previous file with comments | « webrtc/tools/py_event_log_analyzer/rtp_analyzer.py ('k') | webrtc/tools/video_analysis_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698