|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | import os |
| 3 | +import sys |
3 | 4 | from common import TestExtendedInput |
4 | 5 | from nose.tools import eq_ |
5 | 6 |
|
6 | 7 |
|
| 8 | +PY2 = sys.version_info[0] == 2 |
| 9 | + |
| 10 | + |
7 | 11 | def test_issue_4(): |
8 | 12 | myinput = TestExtendedInput() |
9 | 13 | fixture = os.path.join("tests", "fixtures", "issue4-broken.csv") |
10 | | - with open(fixture, "r") as f: |
11 | | - array = myinput.get_array(field_name=('csv', f), encoding='latin1') |
12 | | - expected = [ |
13 | | - [u'Last Name', u'First Name', u'Company', u'Email', u'Job Title'], |
14 | | - [u'Test', u'Th\xefs', u'Cool Co', |
15 | | - u'test.this@example.com', u'Founder'] |
16 | | - ] |
17 | | - eq_(array, expected) |
| 14 | + |
| 15 | + expected = [ |
| 16 | + [u'Last Name', u'First Name', u'Company', u'Email', u'Job Title'], |
| 17 | + [u'Test', u'Th\xefs', u'Cool Co', |
| 18 | + u'test.this@example.com', u'Founder'] |
| 19 | + ] |
| 20 | + if PY2: |
| 21 | + with open(fixture, "rb") as f: |
| 22 | + array = myinput.get_array(field_name=('csv', f), |
| 23 | + encoding='latin1') |
| 24 | + eq_(array, expected) |
| 25 | + else: |
| 26 | + with open(fixture, "r", encoding='latin1') as f: |
| 27 | + array = myinput.get_array(field_name=('csv', f)) |
| 28 | + eq_(array, expected) |
| 29 | + |
0 commit comments