Skip to content

Commit

Permalink
Fix the test for python 3 support while maintaining python 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
paraita committed Jan 24, 2017
1 parent 580429d commit dd4609c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ python:
- "3.4"
- "3.5"
- "3.6"

install:
- pip install .
- pip install coverage
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ pbr==1.10.0
python-dateutil==2.6.0
requests==2.12.4
six==1.10.0
sophiabus230==0.1
5 changes: 4 additions & 1 deletion sophiabus230/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _parse_entry(entry):
bus_time.replace(tzinfo=tz_paris)
idx_start_direction = 3
dest = ' '.join(split_entry[idx_start_direction:idx_end_direction])
dest = dest.encode('utf-8')
dest = dest
return {'bus_time': bus_time, 'dest': dest, 'is_real_time': is_real_time}


Expand Down Expand Up @@ -104,3 +104,6 @@ def get_next_buses(debug=False):
logging.info('found {0}'.format(sane_entry.encode('utf-8')))
tt.append(_parse_entry(sane_entry))
return tt


get_next_buses()
6 changes: 3 additions & 3 deletions sophiabus230/tests/test_get_next_buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestSophiabus230(TestCase):
@patch('sophiabus230._get_html_from_cg06')
def test_get_next_buses(self, mock_content):
parent_path = os.path.dirname(os.path.abspath(__file__))
with open(parent_path + os.sep + "example_content.html", 'r') as fd:
with open(parent_path + os.sep + "example_content.html", 'rb') as fd:
mock_content.return_value = fd.read()
tz_paris = gettz('Europe/Paris')
result_list = sophiabus230.get_next_buses(debug=True)
Expand All @@ -24,9 +24,9 @@ def test_get_next_buses(self, mock_content):
actual_dest = result_list[0]['dest']
actual_is_real_time = result_list[0]['is_real_time']
actual_bus_time = result_list[0]['bus_time']
expected_dest = 'Cathédrale-Vieille Ville'
expected_dest = u'Cathédrale-Vieille Ville'
expected_is_real_time = True
assert actual_dest == expected_dest
self.assertEqual(actual_dest, expected_dest)
assert actual_is_real_time == expected_is_real_time
assert actual_bus_time.year == expected_bus_time.year
assert actual_bus_time.month == expected_bus_time.month
Expand Down

0 comments on commit dd4609c

Please sign in to comment.