Skip to content

Commit 9d7e75b

Browse files
author
Kevin Kuhl
committed
Code review formatting and compliance. Also use for testing
1 parent 78ee720 commit 9d7e75b

9 files changed

+16
-33
lines changed

ci/requirements-2.7.pip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ py
88
PyCrypto
99
mock
1010
ipython
11-
moto

ci/requirements-3.6.pip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
brotlipy
2-
moto

ci/requirements-3.6.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ fastparquet
2222
beautifulsoup4
2323
s3fs
2424
xarray
25-
ipython
25+
ipython

ci/requirements-3.6_LOCALE.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ psycopg2
1919
beautifulsoup4
2020
s3fs
2121
xarray
22-
ipython
22+
ipython

ci/requirements-3.6_LOCALE_SLOW.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ psycopg2
1919
beautifulsoup4
2020
s3fs
2121
xarray
22-
ipython
22+
ipython

pandas/io/json/json.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ def read_json(path_or_buf=None, orient=None, typ='frame', dtype=True,
349349
# commas and put it in a json list to make a valid json object.
350350

351351
"""
352-
Handle encoded bytes arrays in PY3 and bytes objects from certain
353-
readables before using StringIO.
352+
If PY3 and/or isinstance(json, bytes)
354353
"""
355354
if isinstance(json, bytes):
356355
json = json.decode('utf-8')

pandas/tests/io/json/test_pandas.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
from pandas.compat import (range, lrange, StringIO,
55
OrderedDict, is_platform_32bit)
66
import os
7+
import moto
78
import numpy as np
9+
from pandas.tests.io.parser.test_network import s3_resource
10+
from pandas.tests.io.parser.test_network import tips_file, jsonl_file
811
from pandas import (Series, DataFrame, DatetimeIndex, Timestamp,
912
read_json, compat)
1013
from datetime import timedelta
@@ -990,34 +993,11 @@ def test_read_inline_jsonl(self):
990993
expected = DataFrame([[1, 2], [1, 2]], columns=['a', 'b'])
991994
assert_frame_equal(result, expected)
992995

993-
@pytest.yield_fixture(scope="function")
994-
def testbucket_conn(self):
995-
""" Fixture for test_read_s3_jsonl"""
996-
boto3 = pytest.importorskip('boto3')
997-
moto = pytest.importorskip("moto")
998-
999-
"""
1000-
Start and stop mocking only once, surrounding the test run
1001-
to ensure single context is kept.
1002-
"""
1003-
moto.mock_s3().start()
1004-
1005-
conn = boto3.client('s3')
1006-
conn.create_bucket(Bucket='testbucket')
1007-
yield conn
1008-
1009-
moto.mock_s3().stop()
1010-
1011-
def test_read_s3_jsonl(self, testbucket_conn):
996+
def test_read_s3_jsonl(self, s3_resource):
1012997
pytest.importorskip('s3fs')
1013998
# GH17200
1014999

1015-
body = b'{"a": 1, "b": 2}\n{"b":2, "a" :1}\n'
1016-
testbucket_conn.put_object(Body=body,
1017-
Key='items.jsonl',
1018-
Bucket='testbucket')
1019-
1020-
result = read_json('s3://testbucket/items.jsonl', lines=True)
1000+
result = read_json('s3n://pandas-test/items.jsonl', lines=True)
10211001
expected = DataFrame([[1, 2], [1, 2]], columns=['a', 'b'])
10221002
assert_frame_equal(result, expected)
10231003

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"a": 1, "b": 2}
2+
{"b":2, "a" :1}

pandas/tests/io/parser/test_network.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
def tips_file():
2020
return os.path.join(tm.get_data_path(), 'tips.csv')
2121

22+
@pytest.fixture(scope='module')
23+
def jsonl_file():
24+
return os.path.join(tm.get_data_path(), 'items.jsonl')
2225

2326
@pytest.fixture(scope='module')
2427
def salaries_table():
@@ -27,14 +30,15 @@ def salaries_table():
2730

2831

2932
@pytest.fixture(scope='module')
30-
def s3_resource(tips_file):
33+
def s3_resource(tips_file, jsonl_file):
3134
pytest.importorskip('s3fs')
3235
moto.mock_s3().start()
3336

3437
test_s3_files = [
3538
('tips.csv', tips_file),
3639
('tips.csv.gz', tips_file + '.gz'),
3740
('tips.csv.bz2', tips_file + '.bz2'),
41+
('items.jsonl', jsonl_file),
3842
]
3943

4044
def add_tips_files(bucket_name):

0 commit comments

Comments
 (0)