test: fix Python unittests in ./test and ./tools

Co-authored-by: @patrickhousley

Fixes to Python tests to ensure that the following all pass:
1. __python2 -m pytest ./test ./tools__  # 30 tests pass
2. __python3 -m pytest ./test ./tools__  # 30 tests pass
3. __python2 -m unittest discover -s ./test/tools__  # 1 test passes
4. __python3 -m unittest discover -s ./test/tools__  # 1 test passes
5. __PYTHON=python2 make tooltest__   # 1 test passes
6. __PYTHON=python3 make tooltest__   # 1 test passes

This is a subset of #30033

PR-URL: https://github.com/nodejs/node/pull/30340
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
This commit is contained in:
cclauss committed 2019-11-11 10:44:54 +01:00
1 parent 8ac771b809
commit e6a58a89cb
7 files changed
+28 -13

No files matched your search

+1 -1
View File
@@ -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:
File renamed without changes.
+6 -2
View File
@@ -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."""
+6 -2
View File
@@ -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 re
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
+6 -2
View File
@@ -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(
+6 -2
View File
@@ -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(
+3 -4
View File
@@ -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):