Переглянути джерело

Fix failing tests on python3

Oz N Tiram 8 роки тому
батько
коміт
5e3eb9d0bf
2 змінених файлів з 15 додано та 8 видалено
  1. 12 5
      pwman/data/nodes.py
  2. 3 3
      tests/test_base_ui.py

+ 12 - 5
pwman/data/nodes.py

@@ -73,11 +73,18 @@ class Node(object):
         the encrypted entities from the database
         """
         node = Node(clear_text=False)
-        node._username = bytes(username, 'utf8').strip()
-        node._password = bytes(password, 'utf8').strip()
-        node._url = bytes(url, 'utf8').strip()
-        node._notes = bytes(notes, 'utf8').strip()
-        node._tags = [bytes(t, 'utf8').strip() for t in tags]
+        if type(username) == bytes:
+            node._username = username.strip()
+            node._password = password.strip()
+            node._url = url.strip()
+            node._notes = notes.strip()
+            node._tags = [t.strip() for t in tags] 
+        else:
+            node._username = bytes(username, 'utf8').strip()
+            node._password = bytes(password, 'utf8').strip()
+            node._url = bytes(url, 'utf8').strip()
+            node._notes = bytes(notes, 'utf8').strip()
+            node._tags = [bytes(t, 'utf8').strip() for t in tags]
         return node
 
     def __iter__(self):

+ 3 - 3
tests/test_base_ui.py

@@ -92,9 +92,9 @@ class TestBaseUI(unittest.TestCase):
     def test_2_do_list(self):
         self.output = StringIO()
         sys.stdout = self.output
-        self.tester.cli.do_list('')
-        self.tester.cli.do_list('foo')
-        self.tester.cli.do_list('bar')
+        self.tester.cli.do_list(u'')
+        self.tester.cli.do_list(u'foo')
+        self.tester.cli.do_list(u'bar')
         sys.stdout = sys.__stdout__
         self.output.getvalue()