Skip to content

Commit 22a2008

Browse files
committed
[mw] Fix more tests after migration to Python 3
1 parent 18504d8 commit 22a2008

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

patzilla/access/epo/ops/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def handle_error(response, location):
907907
if len(request.errors) == 1:
908908
error_info = request.errors[0].get('description')
909909
if error_info.get('status_code') == 404:
910-
error_content = error_info.get('content', '')
910+
error_content = error_info.get('content', b'')
911911
url = error_info.get('url')
912912
status = str(error_info.get('status_code', '')) + ' ' + error_info.get('reason', '')
913913

patzilla/access/epo/ops/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"""
2222
import json
2323
import logging
24+
import sys
2425
from datetime import date, timedelta
2526

2627
import click
@@ -133,7 +134,7 @@ def image(ctx, document, page, kind, format):
133134
Access the OPS image acquisition API, see OPS handbook section 3.1.3.
134135
"""
135136
payload = get_ops_image(document, page, kind, format)
136-
print(payload)
137+
sys.stdout.buffer.write(payload)
137138

138139

139140
ops_cli.add_command(cmd=usage)

patzilla/util/cql/pyparsing/test/05_misc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ Error explanation
100100
... CQL('foo bar', logging=False).dumps()
101101
... except Exception as ex:
102102
... ex.explanation
103-
'foo bar\n ^\n\nExpected end of text, found 'bar' (at char 4), (line:1, col:5)'
103+
"foo bar\n ^\n\nExpected end of text, found 'bar' (at char 4), (line:1, col:5)"

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ addopts = -rA -vvv
1313
--app-cache-backend=filesystem
1414
patzilla tests -k 'not uspto'
1515

16+
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
17+
1618
log_level = DEBUG
1719
log_cli_level = DEBUG
1820

tests/access/test_epo_ops.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ def test_search_biblio_compact_success(app_request):
7474
assert jpath('/0/pubdate', compact) == "1995-08-09"
7575
assert jpath('/1/pubnumber', compact) == "EP0666667"
7676
assert jpath('/1/pubdate', compact) == "1995-08-09"
77-
assert compact[0].keys() == compact[1].keys() == [
77+
assert sorted(compact[0].keys()) == sorted(compact[1].keys()) == [
78+
'abstract',
7879
'appdate',
7980
'applicant',
80-
'pubdate',
8181
'appnumber',
82-
'title',
83-
'abstract',
84-
'pubnumber',
8582
'inventor',
83+
'pubdate',
84+
'pubnumber',
85+
'title',
8686
]
8787

8888

@@ -573,4 +573,4 @@ def test_register_not_found_failure(app_request):
573573

574574
def test_service_usage(app_request):
575575
response = ops_service_usage("01/01/2022", "02/01/2022")
576-
assert response.keys() == ["response-size", "time-range", "message-count"]
576+
assert sorted(response.keys()) == ["message-count", "response-size", "time-range"]

tests/commands/test_commands_ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def test_command_ops_image_fulldocument_pdf_success():
7676
result = runner.invoke(cli, "ops image --document=EP0666666B1 --page=1", catch_exceptions=False)
7777
assert result.exit_code == 0
7878

79-
assert result.stdout.startswith("b'%PDF-1.4")
80-
assert 30000 < len(result.stdout) < 50000
79+
assert result.stdout_bytes.startswith(b"%PDF-1.4")
80+
assert 30_000 < len(result.stdout_bytes) < 150_000
8181

8282

8383
def test_command_ops_image_fulldocument_tiff_success():
@@ -89,7 +89,7 @@ def test_command_ops_image_fulldocument_tiff_success():
8989
result = runner.invoke(cli, "ops image --document=EP0666666B1 --page=1 --format=tiff", catch_exceptions=False)
9090
assert result.exit_code == 0
9191

92-
assert result.stdout.startswith("b'\x4d\x4d\x00\x2a")
92+
assert result.stdout_bytes.startswith(b"\x4d\x4d\x00\x2a")
9393

9494

9595
def test_command_ops_image_drawing_pdf_success():
@@ -101,8 +101,8 @@ def test_command_ops_image_drawing_pdf_success():
101101
result = runner.invoke(cli, "ops image --document=EP0666666B1 --kind=FullDocumentDrawing --page=1", catch_exceptions=False)
102102
assert result.exit_code == 0
103103

104-
assert result.stdout.startswith("b'%PDF-1.4")
105-
assert 10000 < len(result.stdout) < 20000
104+
assert result.stdout_bytes.startswith(b"%PDF-1.4")
105+
assert 10_000 < len(result.stdout_bytes) < 20_000
106106

107107

108108
def test_command_ops_image_failure():

0 commit comments

Comments
 (0)