-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept a list for the requires attribute (#5371)
* accept a list for the requires attribute * use list for requires in a real conanfile
- Loading branch information
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
49 changes: 49 additions & 0 deletions
49
conans/test/unittests/model/conan_file/create_requirements_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# coding=utf-8 | ||
|
||
import unittest | ||
from collections import namedtuple | ||
|
||
from conans.model.conan_file import create_requirements | ||
|
||
MockConanFile = namedtuple("MockConanFile", ["requires", ]) | ||
|
||
|
||
class TupleTest(unittest.TestCase): | ||
|
||
def test_implicit_tuple(self): | ||
requires = "req/1.0@user/version", "req2/1.0@user/version" | ||
self.assertEqual(type(requires), tuple) | ||
conanfile = MockConanFile(requires=requires) | ||
r = create_requirements(conanfile) | ||
self.assertListEqual(list(r.keys()), ["req", "req2"]) | ||
|
||
def test_tuple(self): | ||
requires = ("req/1.0@user/version", "req2/1.0@user/version") | ||
self.assertEqual(type(requires), tuple) | ||
conanfile = MockConanFile(requires=requires) | ||
r = create_requirements(conanfile) | ||
self.assertListEqual(list(r.keys()), ["req", "req2"]) | ||
|
||
def test_config_tuple(self): | ||
requires = (("req/1.0@user/version", "private"), ) | ||
self.assertEqual(type(requires), tuple) | ||
conanfile = MockConanFile(requires=requires) | ||
r = create_requirements(conanfile) | ||
self.assertListEqual(list(r.keys()), ["req", ]) | ||
|
||
|
||
class ListTest(unittest.TestCase): | ||
|
||
def test_list(self): | ||
requires = ["req/1.0@user/version", "req2/1.0@user/version"] | ||
self.assertEqual(type(requires), list) | ||
conanfile = MockConanFile(requires=requires) | ||
r = create_requirements(conanfile) | ||
self.assertListEqual(list(r.keys()), ["req", "req2"]) | ||
|
||
def test_config_list(self): | ||
requires = [("req/1.0@user/version", "private"), ] | ||
self.assertEqual(type(requires), list) | ||
conanfile = MockConanFile(requires=requires) | ||
r = create_requirements(conanfile) | ||
self.assertListEqual(list(r.keys()), ["req", ]) |