Python 3 fix.

Test: nose2  # With python3 nose2
Bug: None
Change-Id: I84812c55be0daa58a594752702d866daf3c2d8f0
This commit is contained in:
Dan Albert 2018-10-09 15:22:15 -07:00
parent f50b6ce9ba
commit f5b8184abe
1 changed files with 23 additions and 23 deletions

View File

@ -15,7 +15,7 @@
# limitations under the License. # limitations under the License.
# #
"""Tests for gen_stub_libs.py.""" """Tests for gen_stub_libs.py."""
import cStringIO import io
import textwrap import textwrap
import unittest import unittest
@ -200,7 +200,7 @@ class OmitVersionTest(unittest.TestCase):
class SymbolFileParseTest(unittest.TestCase): class SymbolFileParseTest(unittest.TestCase):
def test_next_line(self): def test_next_line(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
foo foo
bar bar
@ -223,7 +223,7 @@ class SymbolFileParseTest(unittest.TestCase):
self.assertEqual('', parser.current_line) self.assertEqual('', parser.current_line)
def test_parse_version(self): def test_parse_version(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { # foo bar VERSION_1 { # foo bar
baz; baz;
qux; # woodly doodly qux; # woodly doodly
@ -253,7 +253,7 @@ class SymbolFileParseTest(unittest.TestCase):
self.assertEqual([], version.tags) self.assertEqual([], version.tags)
def test_parse_version_eof(self): def test_parse_version_eof(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
""")) """))
parser = gsl.SymbolFileParser(input_file, {}) parser = gsl.SymbolFileParser(input_file, {})
@ -262,7 +262,7 @@ class SymbolFileParseTest(unittest.TestCase):
parser.parse_version() parser.parse_version()
def test_unknown_scope_label(self): def test_unknown_scope_label(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
foo: foo:
} }
@ -273,7 +273,7 @@ class SymbolFileParseTest(unittest.TestCase):
parser.parse_version() parser.parse_version()
def test_parse_symbol(self): def test_parse_symbol(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
foo; foo;
bar; # baz qux bar; # baz qux
""")) """))
@ -290,7 +290,7 @@ class SymbolFileParseTest(unittest.TestCase):
self.assertEqual(['baz', 'qux'], symbol.tags) self.assertEqual(['baz', 'qux'], symbol.tags)
def test_wildcard_symbol_global(self): def test_wildcard_symbol_global(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
*; *;
}; };
@ -301,7 +301,7 @@ class SymbolFileParseTest(unittest.TestCase):
parser.parse_version() parser.parse_version()
def test_wildcard_symbol_local(self): def test_wildcard_symbol_local(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
local: local:
*; *;
@ -313,7 +313,7 @@ class SymbolFileParseTest(unittest.TestCase):
self.assertEqual([], version.symbols) self.assertEqual([], version.symbols)
def test_missing_semicolon(self): def test_missing_semicolon(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
foo foo
}; };
@ -325,12 +325,12 @@ class SymbolFileParseTest(unittest.TestCase):
def test_parse_fails_invalid_input(self): def test_parse_fails_invalid_input(self):
with self.assertRaises(gsl.ParseError): with self.assertRaises(gsl.ParseError):
input_file = cStringIO.StringIO('foo') input_file = io.StringIO('foo')
parser = gsl.SymbolFileParser(input_file, {}) parser = gsl.SymbolFileParser(input_file, {})
parser.parse() parser.parse()
def test_parse(self): def test_parse(self):
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
local: local:
hidden1; hidden1;
@ -368,8 +368,8 @@ class GeneratorTest(unittest.TestCase):
def test_omit_version(self): def test_omit_version(self):
# Thorough testing of the cases involved here is handled by # Thorough testing of the cases involved here is handled by
# OmitVersionTest, PrivateVersionTest, and SymbolPresenceTest. # OmitVersionTest, PrivateVersionTest, and SymbolPresenceTest.
src_file = cStringIO.StringIO() src_file = io.StringIO()
version_file = cStringIO.StringIO() version_file = io.StringIO()
generator = gsl.Generator(src_file, version_file, 'arm', 9, False) generator = gsl.Generator(src_file, version_file, 'arm', 9, False)
version = gsl.Version('VERSION_PRIVATE', None, [], [ version = gsl.Version('VERSION_PRIVATE', None, [], [
@ -396,8 +396,8 @@ class GeneratorTest(unittest.TestCase):
def test_omit_symbol(self): def test_omit_symbol(self):
# Thorough testing of the cases involved here is handled by # Thorough testing of the cases involved here is handled by
# SymbolPresenceTest. # SymbolPresenceTest.
src_file = cStringIO.StringIO() src_file = io.StringIO()
version_file = cStringIO.StringIO() version_file = io.StringIO()
generator = gsl.Generator(src_file, version_file, 'arm', 9, False) generator = gsl.Generator(src_file, version_file, 'arm', 9, False)
version = gsl.Version('VERSION_1', None, [], [ version = gsl.Version('VERSION_1', None, [], [
@ -422,8 +422,8 @@ class GeneratorTest(unittest.TestCase):
self.assertEqual('', version_file.getvalue()) self.assertEqual('', version_file.getvalue())
def test_write(self): def test_write(self):
src_file = cStringIO.StringIO() src_file = io.StringIO()
version_file = cStringIO.StringIO() version_file = io.StringIO()
generator = gsl.Generator(src_file, version_file, 'arm', 9, False) generator = gsl.Generator(src_file, version_file, 'arm', 9, False)
versions = [ versions = [
@ -475,7 +475,7 @@ class IntegrationTest(unittest.TestCase):
'P': 9001, 'P': 9001,
} }
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
global: global:
foo; # var foo; # var
@ -508,8 +508,8 @@ class IntegrationTest(unittest.TestCase):
parser = gsl.SymbolFileParser(input_file, api_map) parser = gsl.SymbolFileParser(input_file, api_map)
versions = parser.parse() versions = parser.parse()
src_file = cStringIO.StringIO() src_file = io.StringIO()
version_file = cStringIO.StringIO() version_file = io.StringIO()
generator = gsl.Generator(src_file, version_file, 'arm', 9, False) generator = gsl.Generator(src_file, version_file, 'arm', 9, False)
generator.write(versions) generator.write(versions)
@ -545,7 +545,7 @@ class IntegrationTest(unittest.TestCase):
'Q': 9002, 'Q': 9002,
} }
input_file = cStringIO.StringIO(textwrap.dedent("""\ input_file = io.StringIO(textwrap.dedent("""\
VERSION_1 { VERSION_1 {
global: global:
foo; # introduced=O foo; # introduced=O
@ -558,8 +558,8 @@ class IntegrationTest(unittest.TestCase):
parser = gsl.SymbolFileParser(input_file, api_map) parser = gsl.SymbolFileParser(input_file, api_map)
versions = parser.parse() versions = parser.parse()
src_file = cStringIO.StringIO() src_file = io.StringIO()
version_file = cStringIO.StringIO() version_file = io.StringIO()
generator = gsl.Generator(src_file, version_file, 'arm', 9001, False) generator = gsl.Generator(src_file, version_file, 'arm', 9001, False)
generator.write(versions) generator.write(versions)