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

Proposed by Colin Watson on 2019-08-11
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 on 2019-08-14
Storm Developers 2019-08-11 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.
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

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.

Kristian Glass (doismellburning) wrote :

Right ok, makes sense, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/expr.py'
2--- tests/expr.py 2019-06-07 16:36:44 +0000
3+++ tests/expr.py 2019-08-11 11:10:10 +0000
4@@ -499,10 +499,9 @@
5 self.assertEquals(statement, "child")
6
7 def test_precedence(self):
8- for i in range(10):
9- exec("e%d = SQLRaw('%d')" % (i, i))
10- expr = And(e1, Or(e2, e3),
11- Add(e4, Mul(e5, Sub(e6, Div(e7, Div(e8, e9))))))
12+ e = [SQLRaw('%d' % i) for i in range(10)]
13+ expr = And(e[1], Or(e[2], e[3]),
14+ Add(e[4], Mul(e[5], Sub(e[6], Div(e[7], Div(e[8], e[9]))))))
15 statement = compile(expr)
16 self.assertEquals(statement, "1 AND (2 OR 3) AND 4+5*(6-7/(8/9))")
17
18@@ -2136,10 +2135,9 @@
19 class CompilePythonTest(TestHelper):
20
21 def test_precedence(self):
22- for i in range(10):
23- exec("e%d = SQLRaw('%d')" % (i, i))
24- expr = And(e1, Or(e2, e3),
25- Add(e4, Mul(e5, Sub(e6, Div(e7, Div(e8, e9))))))
26+ e = [SQLRaw('%d' % i) for i in range(10)]
27+ expr = And(e[1], Or(e[2], e[3]),
28+ Add(e[4], Mul(e[5], Sub(e[6], Div(e[7], Div(e[8], e[9]))))))
29 py_expr = compile_python(expr)
30 self.assertEquals(py_expr, "1 and (2 or 3) and 4+5*(6-7/(8/9))")
31
32
33=== modified file 'tests/sqlobject.py'
34--- tests/sqlobject.py 2019-06-05 11:41:07 +0000
35+++ tests/sqlobject.py 2019-08-11 11:10:10 +0000
36@@ -1214,7 +1214,7 @@
37 self.assertEquals([person.name for person in result],
38 [u"John Doe"])
39
40- person.name = u"Funny !%_ Name"
41+ result[0].name = u"Funny !%_ Name"
42
43 expr = NOT(CONTAINSSTRING(self.Person.q.name, u"!%_"))
44 result = self.Person.select(expr)
45
46=== modified file 'tests/variables.py'
47--- tests/variables.py 2019-06-07 17:14:33 +0000
48+++ tests/variables.py 2019-08-11 11:10:10 +0000
49@@ -145,8 +145,9 @@
50 try:
51 variable.set(None)
52 except NoneError as e:
53- pass
54- self.assertTrue("column_name" in str(e))
55+ self.assertTrue("column_name" in str(e))
56+ else:
57+ self.fail("NoneError not raised")
58
59 def test_set_none_with_allow_none_and_column_with_table(self):
60 column = Column("column_name", SQLToken("table_name"))
61@@ -154,8 +155,9 @@
62 try:
63 variable.set(None)
64 except NoneError as e:
65- pass
66- self.assertTrue("table_name.column_name" in str(e))
67+ self.assertTrue("table_name.column_name" in str(e))
68+ else:
69+ self.fail("NoneError not raised")
70
71 def test_set_with_validator(self):
72 args = []

Subscribers

People subscribed via source and target branches

to status/vote changes: