Skip to content

Commit 132806f

Browse files
authored
Merge pull request #35 from ogenstad/py3
Work on Python 3 support
2 parents 40b0d37 + a662cd7 commit 132806f

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
language: python
22
python:
33
- 2.7
4+
- 3.4
5+
- 3.5
46
install:
7+
- pip install -r requirements-dev.txt
58
- pip install -r requirements.txt
69
- pip install .
710
- pip install coveralls

pyIOSXR/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
# License for the specific language governing permissions and limitations under
1818
# the License.
1919

20-
from iosxr import IOSXR
20+
from pyIOSXR.iosxr import IOSXR

pyIOSXR/iosxr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def _execute_rpc(self, command_xml, delay_factor=.1):
361361
response = self._send_command(xml_rpc_command, delay_factor=delay_factor)
362362

363363
try:
364-
root = ET.fromstring(response)
364+
root = ET.fromstring(str.encode(response))
365365
except ET.XMLSyntaxError as xml_err:
366366
if 'IteratorID="' in response:
367367
raise IteratorIDError(self._ITERATOR_ID_ERROR_MSG, self)
@@ -517,7 +517,7 @@ def load_candidate_config(self, filename=None, config=None):
517517
self._execute_rpc(rpc_command)
518518
except InvalidInputError as e:
519519
self.discard_config()
520-
raise InvalidInputError(e.message, self)
520+
raise InvalidInputError(e.args[0], self)
521521

522522
def get_candidate_config(self, merge=False, formal=False):
523523
"""

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
six

test/test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
import unittest
99
from lxml import etree as ET
10+
from six import binary_type
1011

1112
# ~~~ import pyIOSXR modules ~~~
1213
from pyIOSXR import IOSXR
@@ -59,7 +60,8 @@ def get_mock_file(command, format='xml'):
5960
fmt=format
6061
)
6162
fullpath = os.path.join(curr_dir, 'mock', filename)
62-
return open(fullpath).read()
63+
with open(fullpath) as file_data:
64+
return file_data.read()
6365

6466
def find_prompt(self):
6567
return self.get_mock_file('\n', format='txt')
@@ -271,7 +273,7 @@ def test_make_rpc_call_returns_XML(self):
271273

272274
self.assertIsInstance(
273275
self.device.make_rpc_call('<Get><Configuration><NTP></NTP></Configuration></Get>'),
274-
str
276+
binary_type
275277
)
276278

277279
def test_acquired_xml_agent(self):

0 commit comments

Comments
 (0)