Skip to content

Commit

Permalink
Add python 3 support (#1)
Browse files Browse the repository at this point in the history
* Add python 3.4 3.5 and 3.6 support

* Ignore my python 3 virtualenv folder

* Fix the test for python 3 support while maintaining python 2 support
  • Loading branch information
paraita committed Jan 24, 2017
1 parent 6e9cced commit ae1bbfb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -81,6 +81,7 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
ENV3/

# Spyder project settings
.spyderproject
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,9 @@ language: python
python:
- "2.6"
- "2.7"
- "3.4"
- "3.5"
- "3.6"
install:
- pip install .
- pip install coverage
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
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
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
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 ae1bbfb

Please sign in to comment.