Skip to content

Commit

Permalink
Add more tests to cover different iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Nov 6, 2024
1 parent f7d2534 commit e7aba2d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_extension_init(self):
assert ext.name == 'name'

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

# any non-string iterable of strings or PathLike objects should work
ext = Extension('name', ('file1', 'file2')) # tuple
assert ext.sources == ['file1', 'file2']
ext = Extension('name', {'file1', 'file2'}) # set
assert sorted(ext.sources) == ['file1', 'file2']
ext = Extension('name', iter(['file1', 'file2'])) # iterator
assert ext.sources == ['file1', 'file2']
ext = Extension('name', [pathlib.Path('file1'), 'file2']) # mixed types
assert ext.sources == ['file1', 'file2']

# others arguments have defaults
for attr in (
'include_dirs',
Expand Down

0 comments on commit e7aba2d

Please sign in to comment.