diff --git a/Makefile b/Makefile index 356fcf40487e93..d826f56edd3ad5 100644 --- a/Makefile +++ b/Makefile @@ -300,7 +300,7 @@ jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addo .PHONY: tooltest tooltest: - @$(PYTHON) test/tools/test-js2c.py + @$(PYTHON) -m unittest discover -s ./test/tools .PHONY: coverage-run-js coverage-run-js: diff --git a/test/tools/test-js2c.py b/test/tools/test_js2c.py similarity index 100% rename from test/tools/test-js2c.py rename to test/tools/test_js2c.py diff --git a/tools/gyp/pylib/gyp/MSVSSettings_test.py b/tools/gyp/pylib/gyp/MSVSSettings_test.py index bf6ea6b802ff91..245478c8dae4ed 100755 --- a/tools/gyp/pylib/gyp/MSVSSettings_test.py +++ b/tools/gyp/pylib/gyp/MSVSSettings_test.py @@ -6,15 +6,19 @@ """Unit tests for the MSVSSettings.py file.""" -import StringIO import unittest import gyp.MSVSSettings as MSVSSettings +try: + from StringIO import StringIO # Python 2 +except ImportError: + from io import StringIO # Python 3 + class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def _ExpectedWarnings(self, expected): """Compares recorded lines to expected warnings.""" diff --git a/tools/gyp/pylib/gyp/common.py b/tools/gyp/pylib/gyp/common.py index e5ebcd9c9f2f06..351800ee25e23e 100644 --- a/tools/gyp/pylib/gyp/common.py +++ b/tools/gyp/pylib/gyp/common.py @@ -2,7 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import collections import errno import filecmp import os.path @@ -10,6 +9,11 @@ import tempfile import sys +try: + from collections.abc import MutableSet +except ImportError: + from collections import MutableSet + # A minimal memoizing decorator. It'll blow up if the args aren't immutable, # among other "problems". @@ -493,7 +497,7 @@ def uniquer(seq, idfun=None): # Based on http://code.activestate.com/recipes/576694/. -class OrderedSet(collections.MutableSet): +class OrderedSet(MutableSet): def __init__(self, iterable=None): self.end = end = [] end += [None, end, end] # sentinel node for doubly linked list diff --git a/tools/gyp/pylib/gyp/easy_xml_test.py b/tools/gyp/pylib/gyp/easy_xml_test.py index df64354982c01d..664b538a58db60 100755 --- a/tools/gyp/pylib/gyp/easy_xml_test.py +++ b/tools/gyp/pylib/gyp/easy_xml_test.py @@ -8,13 +8,17 @@ import gyp.easy_xml as easy_xml import unittest -import StringIO + +try: + from StringIO import StringIO # Python 2 +except ImportError: + from io import StringIO # Python 3 class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def test_EasyXml_simple(self): self.assertEqual( diff --git a/tools/gyp/pylib/gyp/generator/msvs_test.py b/tools/gyp/pylib/gyp/generator/msvs_test.py index c0b021df502bfa..1b0cdd17201d5b 100755 --- a/tools/gyp/pylib/gyp/generator/msvs_test.py +++ b/tools/gyp/pylib/gyp/generator/msvs_test.py @@ -7,13 +7,17 @@ import gyp.generator.msvs as msvs import unittest -import StringIO + +try: + from StringIO import StringIO # Python 2 +except ImportError: + from io import StringIO # Python 3 class TestSequenceFunctions(unittest.TestCase): def setUp(self): - self.stderr = StringIO.StringIO() + self.stderr = StringIO() def test_GetLibraries(self): self.assertEqual( diff --git a/tools/gyp/pylib/gyp/generator/ninja_test.py b/tools/gyp/pylib/gyp/generator/ninja_test.py index 1767b2f45a04ca..c8adc251c97d50 100644 --- a/tools/gyp/pylib/gyp/generator/ninja_test.py +++ b/tools/gyp/pylib/gyp/generator/ninja_test.py @@ -6,11 +6,10 @@ """ Unit tests for the ninja.py file. """ -import gyp.generator.ninja as ninja -import unittest -import StringIO import sys -import TestCommon +import unittest + +import gyp.generator.ninja as ninja class TestPrefixesAndSuffixes(unittest.TestCase):