Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
python3-ify the test
Browse files Browse the repository at this point in the history
  • Loading branch information
chriddyp committed Feb 2, 2018
1 parent 741e19a commit 546acda
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,30 @@ def setUp(self):

def wait_for_element_by_css_selector(self, selector):
start_time = time.time()
exception = Exception('Time ran out, {} not found'.format(selector))
while time.time() < start_time + 20:
try:
return self.driver.find_element_by_css_selector(selector)
except Exception as e:
exception = e
pass
time.sleep(0.25)
raise e
raise exception

def wait_for_text_to_equal(self, selector, assertion_text):
start_time = time.time()
exception = Exception('Time ran out, {} on {} not found'.format(
assertion_text, selector))
while time.time() < start_time + 20:
el = self.wait_for_element_by_css_selector(selector)
try:
return self.assertEqual(el.text, assertion_text)
except Exception as e:
exception = e
pass
time.sleep(0.25)

raise e
raise exception

def request_queue_assertions(
self, check_rejected=True, expected_length=None):
Expand Down Expand Up @@ -1679,7 +1684,7 @@ def test_initialization_with_overlapping_outputs(self):
def generate_callback(outputid):
def callback(*args):
call_counts[outputid].value += 1
return str(args)
return '{}, {}'.format(*args)
return callback

for i in range(1, 5):
Expand All @@ -1700,7 +1705,7 @@ def callback(*args):
self.assertEqual(call_counts[outputid].value, 1)
self.wait_for_text_to_equal(
'#{}'.format(outputid),
"(u'input-{}', u'input-{}')".format(i, i+1)
"input-{}, input-{}".format(i, i+1)
)

def test_generate_overlapping_outputs(self):
Expand Down Expand Up @@ -1742,7 +1747,7 @@ def display_output(*args):
def generate_callback(outputid):
def callback(*args):
call_counts[outputid].value += 1
return str(args)
return '{}, {}'.format(*args)
return callback

for i in range(1, 5):
Expand All @@ -1764,6 +1769,6 @@ def callback(*args):
self.assertEqual(call_counts[outputid].value, 1)
self.wait_for_text_to_equal(
'#{}'.format(outputid),
"(u'input-{}', u'input-{}')".format(i, i+1)
"input-{}, input-{}".format(i, i+1)
)
self.assertEqual(call_counts['container'].value, 1)

0 comments on commit 546acda

Please sign in to comment.