Merge lp:~cjwatson/storm/py3-tests-prepare-strings into lp:storm
- py3-tests-prepare-strings
- Merge into trunk
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 517 |
Proposed branch: | lp:~cjwatson/storm/py3-tests-prepare-strings |
Merge into: | lp:storm |
Diff against target: |
337 lines (+45/-43) 6 files modified
tests/databases/base.py (+2/-2) tests/databases/postgres.py (+6/-4) tests/expr.py (+16/-16) tests/properties.py (+5/-5) tests/store/base.py (+10/-10) tests/variables.py (+6/-6) |
To merge this branch: | bzr merge lp:~cjwatson/storm/py3-tests-prepare-strings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kristian Glass (community) | Approve | ||
Storm Developers | Pending | ||
Review via email: mp+371165@code.launchpad.net |
Commit message
Be more explicit about string types in tests.
Description of the change
The distinction between '...' and b'...' matters in Python 3, so be explicit where it matters in tests, in preparation for corresponding changes to Storm itself.
To post a comment you must log in.
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
1 | === modified file 'tests/databases/base.py' | |||
2 | --- tests/databases/base.py 2019-06-07 17:14:33 +0000 | |||
3 | +++ tests/databases/base.py 2019-08-11 11:34:17 +0000 | |||
4 | @@ -275,7 +275,7 @@ | |||
5 | 275 | 275 | ||
6 | 276 | def test_binary(self): | 276 | def test_binary(self): |
7 | 277 | """Ensure database works with high bits and embedded zeros.""" | 277 | """Ensure database works with high bits and embedded zeros.""" |
9 | 278 | value = "\xff\x00\xff\x00" | 278 | value = b"\xff\x00\xff\x00" |
10 | 279 | self.connection.execute("INSERT INTO bin_test (b) VALUES (?)", | 279 | self.connection.execute("INSERT INTO bin_test (b) VALUES (?)", |
11 | 280 | (value,)) | 280 | (value,)) |
12 | 281 | result = self.connection.execute("SELECT b FROM bin_test") | 281 | result = self.connection.execute("SELECT b FROM bin_test") |
13 | @@ -290,7 +290,7 @@ | |||
14 | 290 | variable = RawStrVariable() | 290 | variable = RawStrVariable() |
15 | 291 | # If the following doesn't raise a TypeError we're good. | 291 | # If the following doesn't raise a TypeError we're good. |
16 | 292 | result.set_variable(variable, result.get_one()[0]) | 292 | result.set_variable(variable, result.get_one()[0]) |
18 | 293 | self.assertEquals(variable.get(), "Value") | 293 | self.assertEquals(variable.get(), b"Value") |
19 | 294 | 294 | ||
20 | 295 | def test_order_by_group_by(self): | 295 | def test_order_by_group_by(self): |
21 | 296 | self.connection.execute("INSERT INTO test VALUES (100, 'Title 10')") | 296 | self.connection.execute("INSERT INTO test VALUES (100, 'Title 10')") |
22 | 297 | 297 | ||
23 | === modified file 'tests/databases/postgres.py' | |||
24 | --- tests/databases/postgres.py 2019-06-05 11:41:07 +0000 | |||
25 | +++ tests/databases/postgres.py 2019-08-11 11:34:17 +0000 | |||
26 | @@ -147,11 +147,12 @@ | |||
27 | 147 | self.assertEquals(encoding.upper(), "UTF8") | 147 | self.assertEquals(encoding.upper(), "UTF8") |
28 | 148 | 148 | ||
29 | 149 | def test_unicode(self): | 149 | def test_unicode(self): |
31 | 150 | raw_str = "\xc3\xa1\xc3\xa9\xc3\xad\xc3\xb3\xc3\xba" | 150 | raw_str = b"\xc3\xa1\xc3\xa9\xc3\xad\xc3\xb3\xc3\xba" |
32 | 151 | uni_str = raw_str.decode("UTF-8") | 151 | uni_str = raw_str.decode("UTF-8") |
33 | 152 | 152 | ||
34 | 153 | connection = self.database.connect() | 153 | connection = self.database.connect() |
36 | 154 | connection.execute("INSERT INTO test VALUES (1, '%s')" % raw_str) | 154 | connection.execute( |
37 | 155 | (b"INSERT INTO test VALUES (1, '%s')" % raw_str).decode("UTF-8")) | ||
38 | 155 | 156 | ||
39 | 156 | result = connection.execute("SELECT title FROM test WHERE id=1") | 157 | result = connection.execute("SELECT title FROM test WHERE id=1") |
40 | 157 | title = result.get_one()[0] | 158 | title = result.get_one()[0] |
41 | @@ -160,11 +161,12 @@ | |||
42 | 160 | self.assertEquals(title, uni_str) | 161 | self.assertEquals(title, uni_str) |
43 | 161 | 162 | ||
44 | 162 | def test_unicode_array(self): | 163 | def test_unicode_array(self): |
46 | 163 | raw_str = "\xc3\xa1\xc3\xa9\xc3\xad\xc3\xb3\xc3\xba" | 164 | raw_str = b"\xc3\xa1\xc3\xa9\xc3\xad\xc3\xb3\xc3\xba" |
47 | 164 | uni_str = raw_str.decode("UTF-8") | 165 | uni_str = raw_str.decode("UTF-8") |
48 | 165 | 166 | ||
49 | 166 | connection = self.database.connect() | 167 | connection = self.database.connect() |
51 | 167 | result = connection.execute("""SELECT '{"%s"}'::TEXT[]""" % raw_str) | 168 | result = connection.execute( |
52 | 169 | (b"""SELECT '{"%s"}'::TEXT[]""" % raw_str).decode("UTF-8")) | ||
53 | 168 | self.assertEquals(result.get_one()[0], [uni_str]) | 170 | self.assertEquals(result.get_one()[0], [uni_str]) |
54 | 169 | result = connection.execute("""SELECT ?::TEXT[]""", ([uni_str],)) | 171 | result = connection.execute("""SELECT ?::TEXT[]""", ([uni_str],)) |
55 | 170 | self.assertEquals(result.get_one()[0], [uni_str]) | 172 | self.assertEquals(result.get_one()[0], [uni_str]) |
56 | 171 | 173 | ||
57 | === modified file 'tests/expr.py' | |||
58 | --- tests/expr.py 2019-06-07 16:36:44 +0000 | |||
59 | +++ tests/expr.py 2019-08-11 11:34:17 +0000 | |||
60 | @@ -192,7 +192,7 @@ | |||
61 | 192 | 192 | ||
62 | 193 | def test_startswith(self): | 193 | def test_startswith(self): |
63 | 194 | expr = Func1() | 194 | expr = Func1() |
65 | 195 | self.assertRaises(ExprError, expr.startswith, "not a unicode string") | 195 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") |
66 | 196 | 196 | ||
67 | 197 | like_expr = expr.startswith(u"abc!!_%") | 197 | like_expr = expr.startswith(u"abc!!_%") |
68 | 198 | self.assertTrue(isinstance(like_expr, Like)) | 198 | self.assertTrue(isinstance(like_expr, Like)) |
69 | @@ -202,7 +202,7 @@ | |||
70 | 202 | 202 | ||
71 | 203 | def test_endswith(self): | 203 | def test_endswith(self): |
72 | 204 | expr = Func1() | 204 | expr = Func1() |
74 | 205 | self.assertRaises(ExprError, expr.startswith, "not a unicode string") | 205 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") |
75 | 206 | 206 | ||
76 | 207 | like_expr = expr.endswith(u"abc!!_%") | 207 | like_expr = expr.endswith(u"abc!!_%") |
77 | 208 | self.assertTrue(isinstance(like_expr, Like)) | 208 | self.assertTrue(isinstance(like_expr, Like)) |
78 | @@ -213,7 +213,7 @@ | |||
79 | 213 | def test_contains_string(self): | 213 | def test_contains_string(self): |
80 | 214 | expr = Func1() | 214 | expr = Func1() |
81 | 215 | self.assertRaises( | 215 | self.assertRaises( |
83 | 216 | ExprError, expr.contains_string, "not a unicode string") | 216 | ExprError, expr.contains_string, b"not a unicode string") |
84 | 217 | 217 | ||
85 | 218 | like_expr = expr.contains_string(u"abc!!_%") | 218 | like_expr = expr.contains_string(u"abc!!_%") |
86 | 219 | self.assertTrue(isinstance(like_expr, Like)) | 219 | self.assertTrue(isinstance(like_expr, Like)) |
87 | @@ -571,11 +571,11 @@ | |||
88 | 571 | self.assertRaises(CompileError, compile, object()) | 571 | self.assertRaises(CompileError, compile, object()) |
89 | 572 | self.assertRaises(CompileError, compile, [object()]) | 572 | self.assertRaises(CompileError, compile, [object()]) |
90 | 573 | 573 | ||
92 | 574 | def test_str(self): | 574 | def test_bytes(self): |
93 | 575 | state = State() | 575 | state = State() |
95 | 576 | statement = compile("str", state) | 576 | statement = compile(b"str", state) |
96 | 577 | self.assertEquals(statement, "?") | 577 | self.assertEquals(statement, "?") |
98 | 578 | self.assertVariablesEqual(state.parameters, [RawStrVariable("str")]) | 578 | self.assertVariablesEqual(state.parameters, [RawStrVariable(b"str")]) |
99 | 579 | 579 | ||
100 | 580 | def test_unicode(self): | 580 | def test_unicode(self): |
101 | 581 | state = State() | 581 | state = State() |
102 | @@ -1221,11 +1221,11 @@ | |||
103 | 1221 | self.assertVariablesEqual(state.parameters, [Variable("value")]) | 1221 | self.assertVariablesEqual(state.parameters, [Variable("value")]) |
104 | 1222 | 1222 | ||
105 | 1223 | def test_like(self): | 1223 | def test_like(self): |
107 | 1224 | expr = Like(Func1(), "value") | 1224 | expr = Like(Func1(), b"value") |
108 | 1225 | state = State() | 1225 | state = State() |
109 | 1226 | statement = compile(expr, state) | 1226 | statement = compile(expr, state) |
110 | 1227 | self.assertEquals(statement, "func1() LIKE ?") | 1227 | self.assertEquals(statement, "func1() LIKE ?") |
112 | 1228 | self.assertVariablesEqual(state.parameters, [RawStrVariable("value")]) | 1228 | self.assertVariablesEqual(state.parameters, [RawStrVariable(b"value")]) |
113 | 1229 | 1229 | ||
114 | 1230 | expr = Func1().like("Hello") | 1230 | expr = Func1().like("Hello") |
115 | 1231 | state = State() | 1231 | state = State() |
116 | @@ -1234,19 +1234,19 @@ | |||
117 | 1234 | self.assertVariablesEqual(state.parameters, [Variable("Hello")]) | 1234 | self.assertVariablesEqual(state.parameters, [Variable("Hello")]) |
118 | 1235 | 1235 | ||
119 | 1236 | def test_like_escape(self): | 1236 | def test_like_escape(self): |
121 | 1237 | expr = Like(Func1(), "value", "!") | 1237 | expr = Like(Func1(), b"value", b"!") |
122 | 1238 | state = State() | 1238 | state = State() |
123 | 1239 | statement = compile(expr, state) | 1239 | statement = compile(expr, state) |
124 | 1240 | self.assertEquals(statement, "func1() LIKE ? ESCAPE ?") | 1240 | self.assertEquals(statement, "func1() LIKE ? ESCAPE ?") |
125 | 1241 | self.assertVariablesEqual(state.parameters, | 1241 | self.assertVariablesEqual(state.parameters, |
127 | 1242 | [RawStrVariable("value"), RawStrVariable("!")]) | 1242 | [RawStrVariable(b"value"), RawStrVariable(b"!")]) |
128 | 1243 | 1243 | ||
130 | 1244 | expr = Func1().like("Hello", "!") | 1244 | expr = Func1().like("Hello", b"!") |
131 | 1245 | state = State() | 1245 | state = State() |
132 | 1246 | statement = compile(expr, state) | 1246 | statement = compile(expr, state) |
133 | 1247 | self.assertEquals(statement, "func1() LIKE ? ESCAPE ?") | 1247 | self.assertEquals(statement, "func1() LIKE ? ESCAPE ?") |
134 | 1248 | self.assertVariablesEqual(state.parameters, | 1248 | self.assertVariablesEqual(state.parameters, |
136 | 1249 | [Variable("Hello"), RawStrVariable("!")]) | 1249 | [Variable("Hello"), RawStrVariable(b"!")]) |
137 | 1250 | 1250 | ||
138 | 1251 | def test_like_compareable_case(self): | 1251 | def test_like_compareable_case(self): |
139 | 1252 | expr = Func1().like("Hello") | 1252 | expr = Func1().like("Hello") |
140 | @@ -1257,11 +1257,11 @@ | |||
141 | 1257 | self.assertEquals(expr.case_sensitive, False) | 1257 | self.assertEquals(expr.case_sensitive, False) |
142 | 1258 | 1258 | ||
143 | 1259 | def test_in(self): | 1259 | def test_in(self): |
145 | 1260 | expr = In(Func1(), "value") | 1260 | expr = In(Func1(), b"value") |
146 | 1261 | state = State() | 1261 | state = State() |
147 | 1262 | statement = compile(expr, state) | 1262 | statement = compile(expr, state) |
148 | 1263 | self.assertEquals(statement, "func1() IN (?)") | 1263 | self.assertEquals(statement, "func1() IN (?)") |
150 | 1264 | self.assertVariablesEqual(state.parameters, [RawStrVariable("value")]) | 1264 | self.assertVariablesEqual(state.parameters, [RawStrVariable(b"value")]) |
151 | 1265 | 1265 | ||
152 | 1266 | expr = In(Func1(), elem1) | 1266 | expr = In(Func1(), elem1) |
153 | 1267 | state = State() | 1267 | state = State() |
154 | @@ -2166,8 +2166,8 @@ | |||
155 | 2166 | self.assertRaises(CompileError, compile_python, Expr()) | 2166 | self.assertRaises(CompileError, compile_python, Expr()) |
156 | 2167 | self.assertRaises(CompileError, compile_python, Func1()) | 2167 | self.assertRaises(CompileError, compile_python, Func1()) |
157 | 2168 | 2168 | ||
160 | 2169 | def test_str(self): | 2169 | def test_bytes(self): |
161 | 2170 | py_expr = compile_python("str") | 2170 | py_expr = compile_python(b"str") |
162 | 2171 | self.assertEquals(py_expr, "'str'") | 2171 | self.assertEquals(py_expr, "'str'") |
163 | 2172 | 2172 | ||
164 | 2173 | def test_unicode(self): | 2173 | def test_unicode(self): |
165 | 2174 | 2174 | ||
166 | === modified file 'tests/properties.py' | |||
167 | --- tests/properties.py 2019-06-05 11:41:07 +0000 | |||
168 | +++ tests/properties.py 2019-08-11 11:34:17 +0000 | |||
169 | @@ -418,8 +418,8 @@ | |||
170 | 418 | self.obj.prop1 = 1 | 418 | self.obj.prop1 = 1 |
171 | 419 | self.assertTrue(isinstance(self.obj.prop1, decimal)) | 419 | self.assertTrue(isinstance(self.obj.prop1, decimal)) |
172 | 420 | 420 | ||
175 | 421 | def test_str(self): | 421 | def test_bytes(self): |
176 | 422 | self.setup(RawStr, default="def", allow_none=False) | 422 | self.setup(RawStr, default=b"def", allow_none=False) |
177 | 423 | 423 | ||
178 | 424 | self.assertTrue(isinstance(self.column1, Column)) | 424 | self.assertTrue(isinstance(self.column1, Column)) |
179 | 425 | self.assertTrue(isinstance(self.column2, Column)) | 425 | self.assertTrue(isinstance(self.column2, Column)) |
180 | @@ -430,7 +430,7 @@ | |||
181 | 430 | self.assertTrue(isinstance(self.variable1, RawStrVariable)) | 430 | self.assertTrue(isinstance(self.variable1, RawStrVariable)) |
182 | 431 | self.assertTrue(isinstance(self.variable2, RawStrVariable)) | 431 | self.assertTrue(isinstance(self.variable2, RawStrVariable)) |
183 | 432 | 432 | ||
185 | 433 | self.assertEquals(self.obj.prop1, "def") | 433 | self.assertEquals(self.obj.prop1, b"def") |
186 | 434 | self.assertRaises(NoneError, setattr, self.obj, "prop1", None) | 434 | self.assertRaises(NoneError, setattr, self.obj, "prop1", None) |
187 | 435 | self.obj.prop2 = None | 435 | self.obj.prop2 = None |
188 | 436 | self.assertEquals(self.obj.prop2, None) | 436 | self.assertEquals(self.obj.prop2, None) |
189 | @@ -454,7 +454,7 @@ | |||
190 | 454 | self.obj.prop2 = None | 454 | self.obj.prop2 = None |
191 | 455 | self.assertEquals(self.obj.prop2, None) | 455 | self.assertEquals(self.obj.prop2, None) |
192 | 456 | 456 | ||
194 | 457 | self.assertRaises(TypeError, setattr, self.obj, "prop1", "str") | 457 | self.assertRaises(TypeError, setattr, self.obj, "prop1", b"str") |
195 | 458 | 458 | ||
196 | 459 | def test_datetime(self): | 459 | def test_datetime(self): |
197 | 460 | self.setup(DateTime, default=0, allow_none=False) | 460 | self.setup(DateTime, default=0, allow_none=False) |
198 | @@ -814,7 +814,7 @@ | |||
199 | 814 | (Bool, BoolVariable, True), | 814 | (Bool, BoolVariable, True), |
200 | 815 | (Int, IntVariable, 1), | 815 | (Int, IntVariable, 1), |
201 | 816 | (Float, FloatVariable, 1.1), | 816 | (Float, FloatVariable, 1.1), |
203 | 817 | (RawStr, RawStrVariable, "str"), | 817 | (RawStr, RawStrVariable, b"str"), |
204 | 818 | (Unicode, UnicodeVariable, u"unicode"), | 818 | (Unicode, UnicodeVariable, u"unicode"), |
205 | 819 | (DateTime, DateTimeVariable, datetime.now()), | 819 | (DateTime, DateTimeVariable, datetime.now()), |
206 | 820 | (Date, DateVariable, date.today()), | 820 | (Date, DateVariable, date.today()), |
207 | 821 | 821 | ||
208 | === modified file 'tests/store/base.py' | |||
209 | --- tests/store/base.py 2019-06-07 17:14:33 +0000 | |||
210 | +++ tests/store/base.py 2019-08-11 11:34:17 +0000 | |||
211 | @@ -427,7 +427,7 @@ | |||
212 | 427 | self.get_cache(self.store).set_size(0) | 427 | self.get_cache(self.store).set_size(0) |
213 | 428 | 428 | ||
214 | 429 | blob = self.store.get(Blob, 20) | 429 | blob = self.store.get(Blob, 20) |
216 | 430 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 430 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
217 | 431 | self.store.flush() | 431 | self.store.flush() |
218 | 432 | del blob | 432 | del blob |
219 | 433 | gc.collect() | 433 | gc.collect() |
220 | @@ -459,7 +459,7 @@ | |||
221 | 459 | self.get_cache(self.store).set_size(0) | 459 | self.get_cache(self.store).set_size(0) |
222 | 460 | 460 | ||
223 | 461 | blob = self.store.get(Blob, 20) | 461 | blob = self.store.get(Blob, 20) |
225 | 462 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 462 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
226 | 463 | self.store.flush() | 463 | self.store.flush() |
227 | 464 | del blob | 464 | del blob |
228 | 465 | gc.collect() | 465 | gc.collect() |
229 | @@ -502,7 +502,7 @@ | |||
230 | 502 | bin = Pickle() | 502 | bin = Pickle() |
231 | 503 | 503 | ||
232 | 504 | blob = self.store.get(Blob, 20) | 504 | blob = self.store.get(Blob, 20) |
234 | 505 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 505 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
235 | 506 | self.store.flush() | 506 | self.store.flush() |
236 | 507 | del blob | 507 | del blob |
237 | 508 | 508 | ||
238 | @@ -4704,7 +4704,7 @@ | |||
239 | 4704 | bin = Pickle() | 4704 | bin = Pickle() |
240 | 4705 | 4705 | ||
241 | 4706 | blob = self.store.get(Blob, 20) | 4706 | blob = self.store.get(Blob, 20) |
243 | 4707 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4707 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
244 | 4708 | self.store.flush() | 4708 | self.store.flush() |
245 | 4709 | 4709 | ||
246 | 4710 | pickle_blob = self.store.get(PickleBlob, 20) | 4710 | pickle_blob = self.store.get(PickleBlob, 20) |
247 | @@ -4726,7 +4726,7 @@ | |||
248 | 4726 | bin = Pickle() | 4726 | bin = Pickle() |
249 | 4727 | 4727 | ||
250 | 4728 | blob = self.store.get(Blob, 20) | 4728 | blob = self.store.get(Blob, 20) |
252 | 4729 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4729 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
253 | 4730 | self.store.flush() | 4730 | self.store.flush() |
254 | 4731 | 4731 | ||
255 | 4732 | pickle_blob = self.store.get(PickleBlob, 20) | 4732 | pickle_blob = self.store.get(PickleBlob, 20) |
256 | @@ -4763,7 +4763,7 @@ | |||
257 | 4763 | bin = CustomPickle() | 4763 | bin = CustomPickle() |
258 | 4764 | 4764 | ||
259 | 4765 | blob = self.store.get(Blob, 20) | 4765 | blob = self.store.get(Blob, 20) |
261 | 4766 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4766 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
262 | 4767 | self.store.flush() | 4767 | self.store.flush() |
263 | 4768 | 4768 | ||
264 | 4769 | pickle_blob = self.store.get(PickleBlob, 20) | 4769 | pickle_blob = self.store.get(PickleBlob, 20) |
265 | @@ -4798,7 +4798,7 @@ | |||
266 | 4798 | blobs = ReferenceSet(Foo.id, PickleBlob.foo_id) | 4798 | blobs = ReferenceSet(Foo.id, PickleBlob.foo_id) |
267 | 4799 | 4799 | ||
268 | 4800 | blob = self.store.get(Blob, 20) | 4800 | blob = self.store.get(Blob, 20) |
270 | 4801 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4801 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
271 | 4802 | self.store.flush() | 4802 | self.store.flush() |
272 | 4803 | 4803 | ||
273 | 4804 | pickle_blob = self.store.get(PickleBlob, 20) | 4804 | pickle_blob = self.store.get(PickleBlob, 20) |
274 | @@ -4828,7 +4828,7 @@ | |||
275 | 4828 | class FooBlobRefSet(Foo): | 4828 | class FooBlobRefSet(Foo): |
276 | 4829 | blobs = ReferenceSet(Foo.id, PickleBlob.foo_id) | 4829 | blobs = ReferenceSet(Foo.id, PickleBlob.foo_id) |
277 | 4830 | blob = self.store.get(Blob, 20) | 4830 | blob = self.store.get(Blob, 20) |
279 | 4831 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4831 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
280 | 4832 | self.store.flush() | 4832 | self.store.flush() |
281 | 4833 | 4833 | ||
282 | 4834 | pickle_blob = self.store.get(PickleBlob, 20) | 4834 | pickle_blob = self.store.get(PickleBlob, 20) |
283 | @@ -4907,7 +4907,7 @@ | |||
284 | 4907 | from the database and is used whenever possible. | 4907 | from the database and is used whenever possible. |
285 | 4908 | """ | 4908 | """ |
286 | 4909 | blob = self.store.get(Blob, 20) | 4909 | blob = self.store.get(Blob, 20) |
288 | 4910 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4910 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
289 | 4911 | class PickleBlob(object): | 4911 | class PickleBlob(object): |
290 | 4912 | __storm_table__ = "bin" | 4912 | __storm_table__ = "bin" |
291 | 4913 | id = Int(primary=True) | 4913 | id = Int(primary=True) |
292 | @@ -4923,7 +4923,7 @@ | |||
293 | 4923 | bin = Pickle() | 4923 | bin = Pickle() |
294 | 4924 | 4924 | ||
295 | 4925 | blob = self.store.get(Blob, 20) | 4925 | blob = self.store.get(Blob, 20) |
297 | 4926 | blob.bin = "\x80\x02}q\x01U\x01aK\x01s." | 4926 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
298 | 4927 | self.store.flush() | 4927 | self.store.flush() |
299 | 4928 | 4928 | ||
300 | 4929 | pickle_blob = self.store.get(PickleBlob, 20) | 4929 | pickle_blob = self.store.get(PickleBlob, 20) |
301 | 4930 | 4930 | ||
302 | === modified file 'tests/variables.py' | |||
303 | --- tests/variables.py 2019-06-07 17:14:33 +0000 | |||
304 | +++ tests/variables.py 2019-08-11 11:34:17 +0000 | |||
305 | @@ -443,10 +443,10 @@ | |||
306 | 443 | 443 | ||
307 | 444 | def test_set_get(self): | 444 | def test_set_get(self): |
308 | 445 | variable = RawStrVariable() | 445 | variable = RawStrVariable() |
313 | 446 | variable.set("str") | 446 | variable.set(b"str") |
314 | 447 | self.assertEquals(variable.get(), "str") | 447 | self.assertEquals(variable.get(), b"str") |
315 | 448 | variable.set(buffer("buffer")) | 448 | variable.set(buffer(b"buffer")) |
316 | 449 | self.assertEquals(variable.get(), "buffer") | 449 | self.assertEquals(variable.get(), b"buffer") |
317 | 450 | self.assertRaises(TypeError, variable.set, u"unicode") | 450 | self.assertRaises(TypeError, variable.set, u"unicode") |
318 | 451 | 451 | ||
319 | 452 | 452 | ||
320 | @@ -456,7 +456,7 @@ | |||
321 | 456 | variable = UnicodeVariable() | 456 | variable = UnicodeVariable() |
322 | 457 | variable.set(u"unicode") | 457 | variable.set(u"unicode") |
323 | 458 | self.assertEquals(variable.get(), u"unicode") | 458 | self.assertEquals(variable.get(), u"unicode") |
325 | 459 | self.assertRaises(TypeError, variable.set, "str") | 459 | self.assertRaises(TypeError, variable.set, b"str") |
326 | 460 | 460 | ||
327 | 461 | 461 | ||
328 | 462 | class DateTimeVariableTest(TestHelper): | 462 | class DateTimeVariableTest(TestHelper): |
329 | @@ -910,7 +910,7 @@ | |||
330 | 910 | # JSONVariable._loads() complains loudly if it does not receive a | 910 | # JSONVariable._loads() complains loudly if it does not receive a |
331 | 911 | # unicode string because it has no way of knowing its encoding. | 911 | # unicode string because it has no way of knowing its encoding. |
332 | 912 | variable = self.variable_type() | 912 | variable = self.variable_type() |
334 | 913 | self.assertRaises(TypeError, variable.set, '"abc"', from_db=True) | 913 | self.assertRaises(TypeError, variable.set, b'"abc"', from_db=True) |
335 | 914 | 914 | ||
336 | 915 | def test_unicode_to_db(self): | 915 | def test_unicode_to_db(self): |
337 | 916 | # JSONVariable._dumps() works around unicode/str handling issues in | 916 | # JSONVariable._dumps() works around unicode/str handling issues in |