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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/user_unittest.py

Issue 1839193004: Run auto-formatter (autopep8) on webkitpy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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
OLDNEW
1 # Copyright (C) 2010 Research in Motion Ltd. All rights reserved. 1 # Copyright (C) 2010 Research in Motion Ltd. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 13 matching lines...) Expand all
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import unittest 29 import unittest
30 30
31 from webkitpy.common.system.outputcapture import OutputCapture 31 from webkitpy.common.system.outputcapture import OutputCapture
32 from webkitpy.common.system.user import User 32 from webkitpy.common.system.user import User
33 33
34
34 class UserTest(unittest.TestCase): 35 class UserTest(unittest.TestCase):
35 36
36 example_user_response = "example user response" 37 example_user_response = "example user response"
37 38
38 def test_prompt_repeat(self): 39 def test_prompt_repeat(self):
39 self.repeatsRemaining = 2 40 self.repeatsRemaining = 2
41
40 def mock_raw_input(message): 42 def mock_raw_input(message):
41 self.repeatsRemaining -= 1 43 self.repeatsRemaining -= 1
42 if not self.repeatsRemaining: 44 if not self.repeatsRemaining:
43 return UserTest.example_user_response 45 return UserTest.example_user_response
44 return None 46 return None
45 self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_ input=mock_raw_input), UserTest.example_user_response) 47 self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining,
48 raw_input=mock_raw_input), UserTest.example _user_response)
46 49
47 def test_prompt_when_exceeded_repeats(self): 50 def test_prompt_when_exceeded_repeats(self):
48 self.repeatsRemaining = 2 51 self.repeatsRemaining = 2
52
49 def mock_raw_input(message): 53 def mock_raw_input(message):
50 self.repeatsRemaining -= 1 54 self.repeatsRemaining -= 1
51 return None 55 return None
52 self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_ input=mock_raw_input), None) 56 self.assertEqual(User.prompt("input", repeat=self.repeatsRemaining, raw_ input=mock_raw_input), None)
53 57
54 def test_prompt_with_multiple_lists(self): 58 def test_prompt_with_multiple_lists(self):
55 def run_prompt_test(inputs, expected_result, can_choose_multiple=False): 59 def run_prompt_test(inputs, expected_result, can_choose_multiple=False):
56 def mock_raw_input(message): 60 def mock_raw_input(message):
57 return inputs.pop(0) 61 return inputs.pop(0)
58 output_capture = OutputCapture() 62 output_capture = OutputCapture()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 for test_case in test_cases: 123 for test_case in test_cases:
120 expected, inputs = test_case 124 expected, inputs = test_case
121 125
122 def mock_raw_input(message): 126 def mock_raw_input(message):
123 self.assertEqual(expected[0], message) 127 self.assertEqual(expected[0], message)
124 return inputs[1] 128 return inputs[1]
125 129
126 result = User().confirm(default=inputs[0], 130 result = User().confirm(default=inputs[0],
127 raw_input=mock_raw_input) 131 raw_input=mock_raw_input)
128 self.assertEqual(expected[1], result) 132 self.assertEqual(expected[1], result)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698