Skip to content

Commit 6d445e4

Browse files
Fix tests for Python 2.6
1 parent 43fe20c commit 6d445e4

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

learnpython/tests/test_flask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase
1+
from unittest2 import TestCase
22

33
from flask import url_for
44

learnpython/tests/test_twill.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
from random import choice, randint
24

35
from twill.commands import config
@@ -8,6 +10,9 @@
810
TEST_PHONE, TEST_SUBJECT, TestCase, Twill
911

1012

13+
IS_PYTHON_26 = sys.version_info[:2] == (2, 6)
14+
15+
1116
class TestViewsWithTwill(TestCase):
1217

1318
def tearDown(self):
@@ -164,13 +169,22 @@ def test_index(self):
164169
c.code(200)
165170
c.url(t.url(self.subscribe_url))
166171

167-
c.follow('Web flow')
168-
c.code(200)
169-
c.url(t.url(self.flows_url) + '#web$')
172+
if IS_PYTHON_26:
173+
c.go(t.url(self.flows_url))
174+
c.code(200)
175+
c.find('Web flow')
176+
c.find('Advanced flow')
170177

171-
c.follow('Advanced flow')
172-
c.code(200)
173-
c.url(t.url(self.flows_url) + '#advanced$')
178+
c.find('<div class="active tab" id="web">')
179+
c.find('<div class="tab" id="advanced">')
180+
else:
181+
c.follow('Web flow')
182+
c.code(200)
183+
c.url(t.url(self.flows_url) + '#web$')
184+
185+
c.follow('Advanced flow')
186+
c.code(200)
187+
c.url(t.url(self.flows_url) + '#advanced$')
174188

175189
c.follow('Learn Python')
176190
c.code(200)

0 commit comments

Comments
 (0)