Skip to content

Commit e7aba2d

Browse files
Add more tests to cover different iterables
1 parent f7d2534 commit e7aba2d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

distutils/tests/test_extension.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_extension_init(self):
6969
assert ext.name == 'name'
7070

7171
# the second argument, which is the list of files, must
72-
# be a list of strings or PathLike objects
72+
# be a list of strings or PathLike objects, and not a string
7373
with pytest.raises(AssertionError):
7474
Extension('name', 'file')
7575
with pytest.raises(AssertionError):
@@ -79,6 +79,16 @@ def test_extension_init(self):
7979
ext = Extension('name', [pathlib.Path('file1'), pathlib.Path('file2')])
8080
assert ext.sources == ['file1', 'file2']
8181

82+
# any non-string iterable of strings or PathLike objects should work
83+
ext = Extension('name', ('file1', 'file2')) # tuple
84+
assert ext.sources == ['file1', 'file2']
85+
ext = Extension('name', {'file1', 'file2'}) # set
86+
assert sorted(ext.sources) == ['file1', 'file2']
87+
ext = Extension('name', iter(['file1', 'file2'])) # iterator
88+
assert ext.sources == ['file1', 'file2']
89+
ext = Extension('name', [pathlib.Path('file1'), 'file2']) # mixed types
90+
assert ext.sources == ['file1', 'file2']
91+
8292
# others arguments have defaults
8393
for attr in (
8494
'include_dirs',

0 commit comments

Comments
 (0)