Skip to content

Commit 388deaf

Browse files
committed
TST: unit test for #1808, don't fail console_encode test on platforms that can't encode unicode character
1 parent 553a2a9 commit 388deaf

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

pandas/tests/test_common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,17 @@ def test_2d_float32(self):
302302
tm.assert_almost_equal(result, expected)
303303

304304
def test_console_encode(self):
305+
import sys
305306

306307
# stub test
307308
# need to mock-out sys.stdin.encoding=None for real test
308309
result = com.console_encode(u"\u05d0")
309-
assert not result == '?'
310+
expected = u"\u05d0".encode(sys.stdin.encoding,
311+
errors='replace')
312+
313+
# lot of console encodings, ISO-8869-1, cp850, etc. won't encode this
314+
# character
315+
self.assertEqual(result, expected)
310316

311317

312318
if __name__ == '__main__':

pandas/tests/test_frame.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,6 +3495,7 @@ def test_to_excel_multiindex(self):
34953495
def test_to_excel_float_format(self):
34963496
try:
34973497
import xlwt
3498+
import openpyxl
34983499
except ImportError:
34993500
raise nose.SkipTest
35003501

pandas/tseries/tests/test_resample.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,24 @@ def test_resample_median_bug_1688(self):
541541
exp = df.asfreq('T')
542542
tm.assert_frame_equal(result, exp)
543543

544+
def test_how_lambda_functions(self):
545+
ts = _simple_ts('1/1/2000', '4/1/2000')
546+
547+
result = ts.resample('M', how=lambda x: x.mean())
548+
exp = ts.resample('M', how='mean')
549+
tm.assert_series_equal(result, exp)
550+
551+
self.assertRaises(Exception, ts.resample, 'M',
552+
how=[lambda x: x.mean(), lambda x: x.std()])
553+
554+
result = ts.resample('M', how={'foo': lambda x: x.mean(),
555+
'bar': lambda x: x.std()})
556+
foo_exp = ts.resample('M', how='mean')
557+
bar_exp = ts.resample('M', how='std')
558+
559+
tm.assert_series_equal(result['foo'], foo_exp)
560+
tm.assert_series_equal(result['bar'], bar_exp)
561+
544562
def _simple_ts(start, end, freq='D'):
545563
rng = date_range(start, end, freq=freq)
546564
return Series(np.random.randn(len(rng)), index=rng)

0 commit comments

Comments
 (0)