##// END OF EJS Templates
test: moved lxml to local imports since this only exists during tests.
marcink -
r1239:95fd13ba default
parent child Browse files
Show More
@@ -29,8 +29,6 b' from urllib import unquote_plus'
29 29
30 30 import pytest
31 31 import rc_testdata
32 from lxml.html import fromstring, tostring
33 from lxml.cssselect import CSSSelector
34 32
35 33 from rhodecode.model.db import User
36 34 from rhodecode.model.meta import Session
@@ -134,6 +132,11 b' class AssertResponse(object):'
134 132 def __init__(self, response):
135 133 self.response = response
136 134
135 def get_imports(self):
136 from lxml.html import fromstring, tostring
137 from lxml.cssselect import CSSSelector
138 return fromstring, tostring, CSSSelector
139
137 140 def one_element_exists(self, css_selector):
138 141 self.get_element(css_selector)
139 142
@@ -154,6 +157,7 b' class AssertResponse(object):'
154 157 assert expected_content in element.value
155 158
156 159 def contains_one_link(self, link_text, href):
160 fromstring, tostring, CSSSelector = self.get_imports()
157 161 doc = fromstring(self.response.body)
158 162 sel = CSSSelector('a[href]')
159 163 elements = [
@@ -162,6 +166,7 b' class AssertResponse(object):'
162 166 self._ensure_url_equal(elements[0].attrib.get('href'), href)
163 167
164 168 def contains_one_anchor(self, anchor_id):
169 fromstring, tostring, CSSSelector = self.get_imports()
165 170 doc = fromstring(self.response.body)
166 171 sel = CSSSelector('#' + anchor_id)
167 172 elements = sel(doc)
@@ -179,12 +184,14 b' class AssertResponse(object):'
179 184 return self._get_elements(css_selector)
180 185
181 186 def _get_elements(self, css_selector):
187 fromstring, tostring, CSSSelector = self.get_imports()
182 188 doc = fromstring(self.response.body)
183 189 sel = CSSSelector(css_selector)
184 190 elements = sel(doc)
185 191 return elements
186 192
187 193 def _element_to_string(self, element):
194 fromstring, tostring, CSSSelector = self.get_imports()
188 195 return tostring(element)
189 196
190 197
@@ -230,7 +237,7 b' def run_test_concurrently(times, raise_c'
230 237 def call_test_func():
231 238 try:
232 239 test_func(*args, **kwargs)
233 except Exception, e:
240 except Exception as e:
234 241 exceptions.append(e)
235 242 if raise_catched_exc:
236 243 raise
@@ -260,11 +267,11 b' def wait_for_url(url, timeout=10):'
260 267 last = 0
261 268 wait = 0.1
262 269
263 while (timeout > last):
270 while timeout > last:
264 271 last = time.time()
265 272 if is_url_reachable(url):
266 273 break
267 elif ((last + wait) > time.time()):
274 elif (last + wait) > time.time():
268 275 # Go to sleep because not enough time has passed since last check.
269 276 time.sleep(wait)
270 277 else:
General Comments 0
You need to be logged in to leave comments. Login now