Skip to content

Commit b3bbff0

Browse files
committed
test unicode locally
1 parent 4d52f95 commit b3bbff0

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

pandas_gbq/tests/test_gbq.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,45 @@ def test_upload_data(self):
15071507
project_id=_get_project_id())
15081508

15091509
assert result['num_rows'][0] == test_size
1510-
1510+
1511+
def test_upload_chinese_unicode_data(self):
1512+
test_id = "2"
1513+
test_size = 6
1514+
df = DataFrame(np.random.randn(6, 4), index=range(6),
1515+
columns=list('ABCD'))
1516+
df.A = u'信用卡'
1517+
1518+
gbq.to_gbq(df, self.destination_table + test_id, _get_project_id(),
1519+
chunksize=10000)
1520+
1521+
result = gbq.read_gbq("SELECT COUNT(*) AS num_rows FROM {0}".format(
1522+
self.destination_table + test_id),
1523+
project_id=_get_project_id())
1524+
1525+
assert result['num_rows'][0] == test_size
1526+
tm.assert_series_equal(result['A'], df['A'])
1527+
1528+
def test_upload_other_unicode_data(self):
1529+
test_id = "3"
1530+
test_size = 3
1531+
df = DataFrame({
1532+
'string': ['Skywalker™', 'lego', 'hülle'],
1533+
'integer': [200, 300, 400],
1534+
'Date': [
1535+
'2017-12-13 17:40:39', '2017-12-13 17:40:39',
1536+
'2017-12-13 17:40:39'
1537+
]
1538+
})
1539+
1540+
gbq.to_gbq(df, self.destination_table + test_id, _get_project_id(),
1541+
chunksize=10000)
1542+
1543+
result = gbq.read_gbq("SELECT COUNT(*) AS num_rows FROM {0}".format(
1544+
self.destination_table + test_id),
1545+
project_id=_get_project_id())
1546+
1547+
assert result['num_rows'][0] == test_size
1548+
tm.assert_series_equal(result['string'], df['string'])
15111549

15121550
class TestToGBQIntegrationWithServiceAccountKeyContents(object):
15131551
# Changes to BigQuery table schema may take up to 2 minutes as of May 2015

0 commit comments

Comments
 (0)