flake8/tests/unit/test_setuptools_command.py
Rogier van der Geer af2f71c910 Convert namespace package names into paths
Namespace packages, which have a name like "namespace.package" need to
be converted to paths in order to be found by flake8 - as the code
is in "namespace/package/".
2019-12-13 12:19:25 +01:00

35 lines
849 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',
'namespace.bar',
],
})
@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',
'namespace/bar',
]