mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
In our setuptools integration command, we were attempting to avoid checking each submodule in the packages list. This was done without recognizing that two modules may start with the same prefix, e.g., - foo - foo_bar - foo_biz In this case, we only ever checked ``foo``. By appending a '.' to the end of each package name, we avoid this since we only care about deduplicating submodules, e.g., - foo - foo.sub - foo.sub.sub Closes #295
34 lines
796 B
Python
34 lines
796 B
Python
"""Module containing tests for the setuptools command integration."""
|
|
import pytest
|
|
|
|
from setuptools import dist
|
|
|
|
from flake8.main import setuptools_command
|
|
|
|
|
|
@pytest.fixture
|
|
def distribution():
|
|
"""Create a setuptools Distribution object."""
|
|
return dist.Distribution({
|
|
'name': 'foo',
|
|
'packages': [
|
|
'foo',
|
|
'foo.bar',
|
|
'foo_biz',
|
|
],
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def command(distribution):
|
|
"""Create an instance of Flake8's setuptools command."""
|
|
return setuptools_command.Flake8(distribution)
|
|
|
|
|
|
def test_package_files_removes_submodules(command):
|
|
"""Verify that we collect all package files."""
|
|
package_files = list(command.package_files())
|
|
assert sorted(package_files) == [
|
|
'foo',
|
|
'foo_biz',
|
|
]
|