Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix Python unittests #1961

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ matrix:

install:
#- pip install -r requirements.txt
- pip install flake8 # pytest # add another testing frameworks later
- pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python
before_script:
- flake8 --version
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -96,7 +96,7 @@ before_script:
script:
- node -e 'require("npmlog").level="verbose"; require("./lib/find-python")(null,()=>{})'
- npm test
#- pytest --capture=sys # add other tests here
- GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" pytest
notifications:
on_success: change
on_failure: change # `always` will be the setting once code changes slow down
2 changes: 1 addition & 1 deletion gyp/gyp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def UnixifyPath(path):
out = subprocess.Popen(["cygpath", "-u", path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout, stderr = out.communicate()
stdout, _ = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return str(stdout)
Expand Down
2 changes: 2 additions & 0 deletions gyp/pylib/gyp/MSVSSettings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ def testConvertToMSBuildSettings_full_synthetic(self):
'GenerateManifest': 'true',
'IgnoreImportLibrary': 'true',
'LinkIncremental': 'false'}}
self.maxDiff = 9999 # on failure display a long diff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.maxDiff = None if you don't really want an upper limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. These are reasonable limits for these test results.

actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
msvs_settings,
self.stderr)
Expand Down Expand Up @@ -1476,6 +1477,7 @@ def testConvertToMSBuildSettings_actual(self):
'ResourceOutputFileName':
'$(IntDir)$(TargetFileName).embed.manifest.resfdsf'}
}
self.maxDiff = 9999 # on failure display a long diff
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
msvs_settings,
self.stderr)
Expand Down
8 changes: 6 additions & 2 deletions gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,6 +10,11 @@
import sys
import subprocess

try:
from collections.abc import MutableSet
except ImportError:
from collections import MutableSet

PY3 = bytes != str


Expand Down Expand Up @@ -496,7 +500,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
Expand Down
14 changes: 3 additions & 11 deletions gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import subprocess
import sys

from collections import OrderedDict

import gyp.common
import gyp.easy_xml as easy_xml
import gyp.generator.ninja as ninja_generator
Expand All @@ -27,16 +29,6 @@

PY3 = bytes != str

# TODO: Remove once bots are on 2.7, http://crbug.com/241769
def _import_OrderedDict():
import collections
try:
return collections.OrderedDict
except AttributeError:
import gyp.ordered_dict
return gyp.ordered_dict.OrderedDict
OrderedDict = _import_OrderedDict()


# Regular expression for validating Visual Studio GUIDs. If the GUID
# contains lowercase hex letters, MSVS will be fine. However,
Expand Down Expand Up @@ -179,7 +171,7 @@ def _FixPath(path):


def _IsWindowsAbsPath(path):
"""
r"""
On Cygwin systems Python needs a little help determining if a path is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:

Expand Down
1 change: 0 additions & 1 deletion gyp/pylib/gyp/generator/ninja_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import gyp.generator.ninja as ninja
import unittest
import sys
import TestCommon


class TestPrefixesAndSuffixes(unittest.TestCase):
Expand Down
Loading