LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 def _wait_for_server(): | 75 def _wait_for_server(): |
76 """Test the server started by `run_test_server` and fail after 2s. | 76 """Test the server started by `run_test_server` and fail after 2s. |
77 | 77 |
78 Expects the server to be active at `http://localhost:5000/`. | 78 Expects the server to be active at `http://localhost:5000/`. |
79 | 79 |
80 Raises | 80 Raises |
81 ------ | 81 ------ |
82 Exception | 82 Exception |
83 If the server is not running after retry-ing for 2 seconds. | 83 If the server is not running after retry-ing for 2 seconds. |
84 This will be the exception raised by | 84 This will be the exception raised by `urllib2.urlopen`. |
85 | 85 |
86 """ | 86 """ |
87 start_time = time.time() | 87 start_time = time.time() |
88 | 88 |
89 while True: | 89 while True: |
90 try: | 90 try: |
91 urllib2.urlopen('http://localhost:5000/') | 91 urllib2.urlopen('http://localhost:5000/') |
92 break | 92 break |
93 except Exception: | 93 except Exception: |
94 time.sleep(.1) | 94 time.sleep(.1) |
(...skipping 25 matching lines...) Expand all Loading... |
120 | 120 |
121 memory_zip.seek(0) | 121 memory_zip.seek(0) |
122 return memory_zip | 122 return memory_zip |
123 | 123 |
124 | 124 |
125 def exception_test(func, exception, exp_msg, *args, **kw): | 125 def exception_test(func, exception, exp_msg, *args, **kw): |
126 with pytest.raises(exception) as err: | 126 with pytest.raises(exception) as err: |
127 func(*args, **kw) | 127 func(*args, **kw) |
128 | 128 |
129 assert exp_msg in str(err.value) | 129 assert exp_msg in str(err.value) |
LEFT | RIGHT |