From 5d6c158ab8b2d2701bf22add64c2bf41b19f9a34 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Mon, 25 Nov 2013 19:10:19 +0100 Subject: added unittests for file_stream --- test/fulltest.sh | 2 +- test/unittest_scoped_nodes.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/fulltest.sh b/test/fulltest.sh index bfb28ffe..44999b45 100755 --- a/test/fulltest.sh +++ b/test/fulltest.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ $@ ] ; then +if [ $# -ne 0 ] ; then PYVERSIONS=$@ else PYVERSIONS="2.5 2.6 2.7 3.2 3.3" diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py index a967473c..003a46e4 100644 --- a/test/unittest_scoped_nodes.py +++ b/test/unittest_scoped_nodes.py @@ -19,6 +19,8 @@ function) """ +from __future__ import with_statement + import sys from os.path import join, abspath, dirname @@ -164,6 +166,18 @@ del appli del sys.path[1] + 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) + + def test_file_stream_physical(self): + path = join(DATA, 'all.py') + astroid = abuilder.file_build(path, 'all') + with open(path, 'rb') as file_io: + self.assertEqual(astroid.file_stream.read(), file_io.read()) + + class FunctionNodeTC(TestCase): def test_special_attributes(self): -- cgit v1.2.1