Skip to content

Commit b6b0065

Browse files
committed
Remove py2 compat mechanism from test suite
1 parent 63070af commit b6b0065

File tree

9 files changed

+59
-91
lines changed

9 files changed

+59
-91
lines changed

src/crate/client/doctests/client.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ To bulk insert data you can use the ``executemany`` function::
8585
... (name, date, kind, position) VALUES (?, ?, ?, ?)""",
8686
... [('Cloverleaf', '2007-03-11', 'Quasar', 7),
8787
... ('Old Faithful', '2007-03-11', 'Quasar', 7)])
88-
[{u'rowcount': 1}, {u'rowcount': 1}]
88+
[{'rowcount': 1}, {'rowcount': 1}]
8989

9090
``executemany`` returns a list of results for every parameter. Each result
91-
contains a rowcount. If an error occures the rowcount is -2 and the result
91+
contains a rowcount. If an error occurs the rowcount is -2 and the result
9292
may contain an ``error_message`` depending on the error.
9393

9494
Refresh locations:
@@ -112,7 +112,7 @@ fetchone()
112112

113113
>>> result = cursor.fetchone()
114114
>>> pprint(result)
115-
[u'Algol']
115+
['Algol']
116116

117117
If no more data is available, an empty result is returned::
118118

@@ -129,19 +129,19 @@ the specified size of rows::
129129
>>> cursor.execute("SELECT name FROM locations order by name")
130130
>>> result = cursor.fetchmany(2)
131131
>>> pprint(result)
132-
[[u'Aldebaran'], [u'Algol']]
132+
[['Aldebaran'], ['Algol']]
133133

134134
If a size is not given, the cursor's arraysize, which defaults to '1',
135135
determines the number of rows to be fetched::
136136

137137
>>> cursor.fetchmany()
138-
[[u'Allosimanius Syneca']]
138+
[['Allosimanius Syneca']]
139139

140140
It's also possible to change the cursors arraysize to an other value::
141141

142142
>>> cursor.arraysize = 3
143143
>>> cursor.fetchmany()
144-
[[u'Alpha Centauri'], [u'Altair'], [u'Argabuthon']]
144+
[['Alpha Centauri'], ['Altair'], ['Argabuthon']]
145145

146146
fetchall()
147147
----------
@@ -219,7 +219,7 @@ be raised.
219219
>>> cursor.execute("SELECT * FROM locations")
220220
Traceback (most recent call last):
221221
...
222-
ProgrammingError: Cursor closed
222+
crate.client.exceptions.ProgrammingError: Cursor closed
223223

224224
Closing the Connection
225225
======================
@@ -235,9 +235,9 @@ operation using the connection is attempted to a closed connection an
235235
>>> cursor.execute("SELECT * FROM locations")
236236
Traceback (most recent call last):
237237
...
238-
ProgrammingError: Connection closed
238+
crate.client.exceptions.ProgrammingError: Connection closed
239239

240240
>>> cursor = connection.cursor()
241241
Traceback (most recent call last):
242242
...
243-
ProgrammingError: Connection closed
243+
crate.client.exceptions.ProgrammingError: Connection closed

src/crate/client/doctests/connection.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ raise a ``ProgrammingError``::
3434
>>> cursor = connection.cursor()
3535
Traceback (most recent call last):
3636
...
37-
ProgrammingError: Connection closed
37+
crate.client.exceptions.ProgrammingError: Connection closed
3838

3939
>>> cursor.execute('')
4040
Traceback (most recent call last):
4141
...
42-
ProgrammingError: Connection closed
42+
crate.client.exceptions.ProgrammingError: Connection closed
4343

4444
>>> connection.commit()
4545
Traceback (most recent call last):
4646
...
47-
ProgrammingError: Connection closed
47+
crate.client.exceptions.ProgrammingError: Connection closed
4848

4949
>>> connection = connect(client=connection_client_mocked)
5050
>>> cursor = connection.cursor()

src/crate/client/doctests/cursor.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ in an error::
6161
>>> new_cursor.fetchone()
6262
Traceback (most recent call last):
6363
...
64-
ProgrammingError: No result available. execute() or executemany() must be called first.
64+
crate.client.exceptions.ProgrammingError: No result available. execute() or executemany() must be called first.
6565

6666

6767
fetchmany()
@@ -154,7 +154,7 @@ Iterating over a new cursor without results will immediately raise a Programming
154154
>>> next(new_cursor)
155155
Traceback (most recent call last):
156156
...
157-
ProgrammingError: No result available. execute() or executemany() must be called first.
157+
crate.client.exceptions.ProgrammingError: No result available. execute() or executemany() must be called first.
158158

159159
description
160160
===========
@@ -296,20 +296,20 @@ closed connection an ``ProgrammingError`` exception will be raised::
296296
>>> cursor.fetchone()
297297
Traceback (most recent call last):
298298
...
299-
ProgrammingError: Cursor closed
299+
crate.client.exceptions.ProgrammingError: Cursor closed
300300

301301
>>> cursor.fetchmany()
302302
Traceback (most recent call last):
303303
...
304-
ProgrammingError: Cursor closed
304+
crate.client.exceptions.ProgrammingError: Cursor closed
305305

306306
>>> cursor.fetchall()
307307
Traceback (most recent call last):
308308
...
309-
ProgrammingError: Cursor closed
309+
crate.client.exceptions.ProgrammingError: Cursor closed
310310

311311
>>> cursor.next()
312312
Traceback (most recent call last):
313313
...
314-
ProgrammingError: Cursor closed
314+
crate.client.exceptions.ProgrammingError: Cursor closed
315315

src/crate/client/doctests/http.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,22 @@ Issue a select statement against our with test data pre-filled crate instance::
6969
>>> http_client = HttpClient(crate_host)
7070
>>> result = http_client.sql('select name from locations order by name')
7171
>>> pprint(result)
72-
{u'cols': [u'name'],
73-
u'duration': ...,
74-
u'rowcount': 13,
75-
u'rows': [['Aldebaran'],
76-
['Algol'],
77-
['Allosimanius Syneca'],
78-
['Alpha Centauri'],
79-
['Altair'],
80-
['Argabuthon'],
81-
['Arkintoofle Minor'],
82-
['Bartledan'],
83-
['Folfanga'],
84-
['Galactic Sector QQ7 Active J Gamma'],
85-
['Galaxy'],
86-
['North West Ripple'],
87-
['Outer Eastern Rim']]}
72+
{'cols': ['name'],
73+
'duration': ...,
74+
'rowcount': 13,
75+
'rows': [['Aldebaran'],
76+
['Algol'],
77+
['Allosimanius Syneca'],
78+
['Alpha Centauri'],
79+
['Altair'],
80+
['Argabuthon'],
81+
['Arkintoofle Minor'],
82+
['Bartledan'],
83+
['Folfanga'],
84+
['Galactic Sector QQ7 Active J Gamma'],
85+
['Galaxy'],
86+
['North West Ripple'],
87+
['Outer Eastern Rim']]}
8888

8989
Blobs
9090
=====
@@ -99,7 +99,7 @@ Trying to get a non-existing blob throws an exception::
9999
>>> http_client.blob_get('myfiles', '041f06fd774092478d450774f5ba30c5da78acc8')
100100
Traceback (most recent call last):
101101
...
102-
DigestNotFoundException: myfiles/041f06fd774092478d450774f5ba30c5da78acc8
102+
crate.client.exceptions.DigestNotFoundException: myfiles/041f06fd774092478d450774f5ba30c5da78acc8
103103

104104
Creating a new blob - this method returns True if the blob was newly
105105
created, false if it already exists::
@@ -153,7 +153,7 @@ Uploading a blob to a table with disabled blob support throws an exception::
153153
... 'locations', '040f06fd774092478d450774f5ba30c5da78acc8', f)
154154
Traceback (most recent call last):
155155
...
156-
BlobLocationNotFoundException: locations/040f06fd774092478d450774f5ba30c5da78acc8
156+
crate.client.exceptions.BlobLocationNotFoundException: locations/040f06fd774092478d450774f5ba30c5da78acc8
157157

158158
Error Handling
159159
==============
@@ -179,15 +179,15 @@ an exception is raised when the timeout is reached::
179179
>>> http_client.sql('select fib(32)')
180180
Traceback (most recent call last):
181181
...
182-
ConnectionError: No more Servers available, exception from last server: ...
182+
crate.client.exceptions.ConnectionError: No more Servers available, exception from last server: ...
183183

184184
When connecting to non Crate servers the HttpClient will raise a ConnectionError like this::
185185

186186
>>> http_client = HttpClient(["https://crate.io"])
187187
>>> http_client.server_infos(http_client._get_server())
188188
Traceback (most recent call last):
189189
...
190-
ProgrammingError: Invalid server response of content-type 'text/html; charset=UTF-8':
190+
crate.client.exceptions.ProgrammingError: Invalid server response of content-type 'text/html; charset=UTF-8':
191191
...
192192

193193
When using the ``error_trace`` kwarg a full traceback of the server exception

src/crate/client/doctests/https.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ a self signed certificate::
3131

3232
>>> http_client = HttpClient([crate_host])
3333
>>> http_client.server_infos(http_client._get_server())
34-
('https://localhost:65534', u'test', '0.0.0')
34+
('https://localhost:65534', 'test', '0.0.0')
3535

3636
When switching on verification without a ``ca_cert`` file provided, the
3737
connection will fail::
@@ -40,28 +40,28 @@ connection will fail::
4040
>>> verifying_client.server_infos(crate_host)
4141
Traceback (most recent call last):
4242
...
43-
ConnectionError: Server not available, ...certificate verify failed...
43+
crate.client.exceptions.ConnectionError: Server not available, ...certificate verify failed...
4444

4545
Also when providing an invalid ``ca_cert`` an error is raised::
4646

4747
>>> verifying_client = HttpClient([crate_host], ca_cert=invalid_ca_cert, verify_ssl_cert=True)
4848
>>> verifying_client.server_infos(crate_host)
4949
Traceback (most recent call last):
5050
...
51-
ConnectionError: Server not available, ...certificate verify failed...
51+
crate.client.exceptions.ConnectionError: Server not available, ...certificate verify failed...
5252

5353
Without verification, the given ``ca_cert`` is ignored and the connection will be
5454
established, to Eves satisfaction.
5555

5656
>>> non_verifying_client = HttpClient([crate_host], ca_cert=invalid_ca_cert, verify_ssl_cert=False)
5757
>>> non_verifying_client.server_infos(crate_host)
58-
('https://localhost:65534', u'test', '0.0.0')
58+
('https://localhost:65534', 'test', '0.0.0')
5959

6060
Connecting to a host whose certificate is verified with a valid CA certificate::
6161

6262
>>> verifying_valid_client = HttpClient([crate_host], ca_cert=valid_ca_cert, verify_ssl_cert=True)
6363
>>> verifying_valid_client.server_infos(verifying_valid_client._get_server())
64-
('https://localhost:65534', u'test', '0.0.0')
64+
('https://localhost:65534', 'test', '0.0.0')
6565

6666

6767
Client Certificate
@@ -80,5 +80,5 @@ invalid::
8080
>>> client.server_infos(crate_host)
8181
Traceback (most recent call last):
8282
...
83-
ConnectionError: Server not available, exception: ...[SSL: ...
83+
crate.client.exceptions.ConnectionError: Server not available, exception: ...[SSL: ...
8484

src/crate/client/doctests/sqlalchemy.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ be left untouched.
135135
>>> session.refresh(char)
136136

137137
>>> char.details['gender']
138-
u'manly man'
138+
'manly man'
139139

140140
>>> char.details['species']
141-
u'human'
141+
'human'
142142

143143
Object Array
144144
------------
@@ -173,7 +173,7 @@ to be returned::
173173
>>> from sqlalchemy.sql import operators
174174
>>> query = session.query(Character.name)
175175
>>> query.filter(Character.more_details['foo'].any(1, operator=operators.eq)).all()
176-
[(u'Arthur Dent',)]
176+
[('Arthur Dent',)]
177177

178178
Querying a field of an object array will result in an array of
179179
all values of that field of all objects in that object array::
@@ -208,7 +208,7 @@ Using the ``group_by`` clause is similar::
208208
... .group_by(Character.name) \
209209
... .order_by(sa.desc(sa.func.count(Character.id))) \
210210
... .order_by(Character.name).all()
211-
[(1, u'Arthur Dent'), (1, u'Tricia McMillan')]
211+
[(1, 'Arthur Dent'), (1, 'Tricia McMillan')]
212212

213213
Fulltext Search with MATCH Predicate
214214
====================================
@@ -260,7 +260,7 @@ The default match_type is best_fields::
260260
... options={'fuzziness': 3})
261261
... ) \
262262
... .all()
263-
[(u'Arthur Dent',)]
263+
[('Arthur Dent',)]
264264

265265
It's not possible to specify options without the match_type argument::
266266

@@ -376,4 +376,4 @@ This will result in the following query::
376376
... "(SELECT todos.id, todos.content FROM todos WHERE todos.status = 'done')"
377377

378378
>>> pprint([str(r) for r in session.execute("Select content from archived_tasks")])
379-
["(u'Write Tests',)"]
379+
["('Write Tests',)"]

src/crate/client/sqlalchemy/doctests/itests.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Using the connection to execute a select statement::
1111
13
1212

1313
>>> result.first()
14-
(u'Aldebaran',)
14+
('Aldebaran',)
1515

1616
Using the ORM to query the locations::
1717

@@ -29,14 +29,14 @@ With filter::
2929

3030
>>> location = session.query(Location).filter_by(name='Algol').one()
3131
>>> location.name
32-
u'Algol'
32+
'Algol'
3333

3434
Order by::
3535

3636
>>> locations = session.query(Location).filter(Location.name != None).order_by(sa.desc(Location.name))
3737
>>> locations = locations.limit(2)
3838
>>> [l.name for l in locations]
39-
[u'Outer Eastern Rim', u'North West Ripple']
39+
['Outer Eastern Rim', 'North West Ripple']
4040

4141

4242
Insert a new location::
@@ -58,13 +58,13 @@ Inserted location is available::
5858

5959
>>> location = session.query(Location).filter_by(name='Earth').one()
6060
>>> location.name
61-
u'Earth'
61+
'Earth'
6262

6363
Retrieve the location from the database::
6464

6565
>>> session.refresh(location)
6666
>>> location.name
67-
u'Earth'
67+
'Earth'
6868

6969
Date should have been set at the insert due to default value via python method::
7070

@@ -87,10 +87,10 @@ Date should have been set at the insert due to default value via python method::
8787
Verify the return type of date and datetime::
8888

8989
>>> type(location.date)
90-
<type 'datetime.date'>
90+
<class 'datetime.date'>
9191

9292
>>> type(location.datetime)
93-
<type 'datetime.datetime'>
93+
<class 'datetime.datetime'>
9494

9595
the location also has a date and datetime property which both are nullable and
9696
aren't set when the row is inserted as there is no default method::
@@ -165,7 +165,7 @@ Test that objects can be used as list too::
165165
>>> session.refresh(location)
166166

167167
>>> location.details
168-
[{u'size': u'huge'}, {u'clima': u'cold'}]
168+
[{'size': 'huge'}, {'clima': 'cold'}]
169169

170170
Update the clima::
171171

@@ -175,7 +175,7 @@ Update the clima::
175175
>>> session.refresh(location)
176176

177177
>>> location.details
178-
[{u'size': u'huge'}, {u'clima': u'hot'}]
178+
[{'size': 'huge'}, {'clima': 'hot'}]
179179

180180
Reset the clima::
181181

0 commit comments

Comments
 (0)