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

enum cleanup #7269

Merged

deterministically sort requirements from libraries in unpacked_whls()…

… tests
  • Loading branch information...
cosmicexplorer committed Mar 1, 2019
commit 7b4c42c968a56b5b75fc65f7be3dbffa6720e6bb
@@ -4,6 +4,7 @@

from __future__ import absolute_import, division, print_function, unicode_literals

from builtins import str
from textwrap import dedent

from pants.backend.python.python_requirement import PythonRequirement
@@ -56,6 +57,9 @@ def test_has_all_imported_req_libs(self):
def assert_dep(reqA, reqB):
self.assertEqual(reqA.requirement, reqB.requirement)

def sort_requirements(reqs):
return list(sorted(reqs, key=lambda r: str(r.requirement)))

self.add_to_build_file('BUILD', dedent('''
python_requirement_library(name='lib1',
requirements=[
@@ -80,13 +84,13 @@ def assert_dep(reqA, reqB):

lib2 = self.target('//:lib2')
self.assertIsInstance(lib2, PythonRequirementLibrary)
lib2_reqs = list(lib2.requirements)
lib2_reqs = sort_requirements(lib2.requirements)
self.assertEqual(2, len(lib2_reqs))
assert_dep(lib2_reqs[0], PythonRequirement('testName2==456'))
assert_dep(lib2_reqs[1], PythonRequirement('testName3==789'))

unpacked_lib = self.target('//:unpacked-lib')
unpacked_req_libs = unpacked_lib.all_imported_requirements
unpacked_req_libs = sort_requirements(unpacked_lib.all_imported_requirements)

self.assertEqual(3, len(unpacked_req_libs))
assert_dep(unpacked_req_libs[0], PythonRequirement('testName1==123'))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.