Merge lp:~cjwatson/storm/py3-scoping into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 522
Proposed branch: lp:~cjwatson/storm/py3-scoping
Merge into: lp:storm
Diff against target: 72 lines (+13/-13)
3 files modified
tests/expr.py (+6/-8)
tests/sqlobject.py (+1/-1)
tests/variables.py (+6/-4)
To merge this branch: bzr merge lp:~cjwatson/storm/py3-scoping
Reviewer Review Type Date Requested Status
Kristian Glass (community) Approve
Storm Developers Pending
Review via email: mp+371164@code.launchpad.net

Commit message

Adjust tests to cope with tighter scoping rules in Python 3.

To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) wrote :

LGTM - yay for less `exec`ing - though I have two instances of one question about using assertRaises for potentially-better legibility

Revision history for this message
Colin Watson (cjwatson) wrote :

Formally Storm still supports Python 2.6 (that is, we've specifically dropped support for earlier versions but not yet for 2.6). The form of assertRaises that's usable as a context manager to allow performing additional checks on the exception raised was only introduced in 2.7. Although I don't particularly care about 2.6, it felt less invasive to fix this up within the existing version constraints.

Revision history for this message
Kristian Glass (doismellburning) wrote :

Right ok, makes sense, thanks!

Revision history for this message
Kristian Glass (doismellburning) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/expr.py'
--- tests/expr.py 2019-06-07 16:36:44 +0000
+++ tests/expr.py 2019-08-11 11:10:10 +0000
@@ -499,10 +499,9 @@
499 self.assertEquals(statement, "child")499 self.assertEquals(statement, "child")
500500
501 def test_precedence(self):501 def test_precedence(self):
502 for i in range(10):502 e = [SQLRaw('%d' % i) for i in range(10)]
503 exec("e%d = SQLRaw('%d')" % (i, i))503 expr = And(e[1], Or(e[2], e[3]),
504 expr = And(e1, Or(e2, e3),504 Add(e[4], Mul(e[5], Sub(e[6], Div(e[7], Div(e[8], e[9]))))))
505 Add(e4, Mul(e5, Sub(e6, Div(e7, Div(e8, e9))))))
506 statement = compile(expr)505 statement = compile(expr)
507 self.assertEquals(statement, "1 AND (2 OR 3) AND 4+5*(6-7/(8/9))")506 self.assertEquals(statement, "1 AND (2 OR 3) AND 4+5*(6-7/(8/9))")
508507
@@ -2136,10 +2135,9 @@
2136class CompilePythonTest(TestHelper):2135class CompilePythonTest(TestHelper):
21372136
2138 def test_precedence(self):2137 def test_precedence(self):
2139 for i in range(10):2138 e = [SQLRaw('%d' % i) for i in range(10)]
2140 exec("e%d = SQLRaw('%d')" % (i, i))2139 expr = And(e[1], Or(e[2], e[3]),
2141 expr = And(e1, Or(e2, e3),2140 Add(e[4], Mul(e[5], Sub(e[6], Div(e[7], Div(e[8], e[9]))))))
2142 Add(e4, Mul(e5, Sub(e6, Div(e7, Div(e8, e9))))))
2143 py_expr = compile_python(expr)2141 py_expr = compile_python(expr)
2144 self.assertEquals(py_expr, "1 and (2 or 3) and 4+5*(6-7/(8/9))")2142 self.assertEquals(py_expr, "1 and (2 or 3) and 4+5*(6-7/(8/9))")
21452143
21462144
=== modified file 'tests/sqlobject.py'
--- tests/sqlobject.py 2019-06-05 11:41:07 +0000
+++ tests/sqlobject.py 2019-08-11 11:10:10 +0000
@@ -1214,7 +1214,7 @@
1214 self.assertEquals([person.name for person in result],1214 self.assertEquals([person.name for person in result],
1215 [u"John Doe"])1215 [u"John Doe"])
12161216
1217 person.name = u"Funny !%_ Name"1217 result[0].name = u"Funny !%_ Name"
12181218
1219 expr = NOT(CONTAINSSTRING(self.Person.q.name, u"!%_"))1219 expr = NOT(CONTAINSSTRING(self.Person.q.name, u"!%_"))
1220 result = self.Person.select(expr)1220 result = self.Person.select(expr)
12211221
=== modified file 'tests/variables.py'
--- tests/variables.py 2019-06-07 17:14:33 +0000
+++ tests/variables.py 2019-08-11 11:10:10 +0000
@@ -145,8 +145,9 @@
145 try:145 try:
146 variable.set(None)146 variable.set(None)
147 except NoneError as e:147 except NoneError as e:
148 pass148 self.assertTrue("column_name" in str(e))
149 self.assertTrue("column_name" in str(e))149 else:
150 self.fail("NoneError not raised")
150151
151 def test_set_none_with_allow_none_and_column_with_table(self):152 def test_set_none_with_allow_none_and_column_with_table(self):
152 column = Column("column_name", SQLToken("table_name"))153 column = Column("column_name", SQLToken("table_name"))
@@ -154,8 +155,9 @@
154 try:155 try:
155 variable.set(None)156 variable.set(None)
156 except NoneError as e:157 except NoneError as e:
157 pass158 self.assertTrue("table_name.column_name" in str(e))
158 self.assertTrue("table_name.column_name" in str(e))159 else:
160 self.fail("NoneError not raised")
159161
160 def test_set_with_validator(self):162 def test_set_with_validator(self):
161 args = []163 args = []

Subscribers

People subscribed via source and target branches

to status/vote changes: