summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2014-04-02 17:18:02 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2014-04-02 17:18:02 +0300
commit6fa9f3d235f92e1b4f37f947fb475cd6ae7b6375 (patch)
tree233d306fc3c383284b2d5b06ab29b91a1c0546fc
parent5dc3d54286d4dd7cfc92a43ccaf8322c0ded7939 (diff)
downloadastroid-git-6fa9f3d235f92e1b4f37f947fb475cd6ae7b6375.tar.gz
Fix tests for Python 3 and Windows.
-rw-r--r--test/unittest_manager.py11
-rw-r--r--test/unittest_scoped_nodes.py2
2 files changed, 10 insertions, 3 deletions
diff --git a/test/unittest_manager.py b/test/unittest_manager.py
index 9c372b5a..5db186dd 100644
--- a/test/unittest_manager.py
+++ b/test/unittest_manager.py
@@ -24,6 +24,7 @@ from astroid.bases import BUILTINS
from astroid.exceptions import AstroidBuildingException
DATA = join(dirname(abspath(__file__)), 'data')
+PY3K = sys.version_info > (3, 0)
class AstroidManagerTC(TestCase):
def setUp(self):
@@ -89,7 +90,8 @@ class AstroidManagerTC(TestCase):
try:
module = self.manager.ast_from_module_name('mypypa')
self.assertEqual(module.name, 'mypypa')
- self.assertTrue(module.file.endswith('%s/mypypa' % archive),
+ end = join(archive, 'mypypa')
+ self.assertTrue(module.file.endswith(end),
module.file)
finally:
# remove the module, else after importing egg, we don't get the zip
@@ -119,7 +121,12 @@ class AstroidManagerTC(TestCase):
def test_file_from_module(self):
"""check if the unittest filepath is equals to the result of the method"""
import unittest
- self.assertEqual(unittest.__file__[:-1], self.manager.file_from_module_name('unittest', None))
+ if PY3K:
+ unittest_file = unittest.__file__
+ else:
+ unittest_file = unittest.__file__[:-1]
+ self.assertEqual(unittest_file,
+ self.manager.file_from_module_name('unittest', None))
def test_file_from_module_name_astro_building_exception(self):
"""check if the method launch a exception with a wrong module name"""
diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py
index a349ca03..e7399ae9 100644
--- a/test/unittest_scoped_nodes.py
+++ b/test/unittest_scoped_nodes.py
@@ -171,7 +171,7 @@ del appli
def test_file_stream_in_memory(self):
data = '''irrelevant_variable is irrelevant'''
astroid = abuilder.string_build(data, 'in_memory')
- self.assertEqual(astroid.file_stream.read(), data)
+ self.assertEqual(astroid.file_stream.read().decode(), data)
def test_file_stream_physical(self):
path = join(DATA, 'all.py')