Skip to content

Commit

Permalink
add tests for stub-only package name check
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com>
  • Loading branch information
hoefling committed Feb 8, 2020
1 parent d34dfa1 commit 7809999
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Empty file.
4 changes: 4 additions & 0 deletions tests/masonry/utils/fixtures/pep_561_stub_only/bad/module.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Example module"""
from typing import Tuple

version_info = Tuple[int, int, int]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Example module"""
from typing import Tuple

version_info = Tuple[int, int, int]
17 changes: 17 additions & 0 deletions tests/masonry/utils/test_package_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@ def test_package_include_with_no_python_files_in_dir():
PackageInclude(base=with_includes, include="not_a_python_pkg")

assert str(e.value) == "not_a_python_pkg is not a package."


def test_pep_561_stub_only_package_good_name_suffix():
pkg_include = PackageInclude(
base=fixtures_dir / "pep_561_stub_only", include="good-stubs"
)
assert pkg_include.elements == [
fixtures_dir / "pep_561_stub_only/good-stubs/__init__.pyi",
fixtures_dir / "pep_561_stub_only/good-stubs/module.pyi",
]


def test_pep_561_stub_only_package_bad_name_suffix():
with pytest.raises(ValueError) as e:
PackageInclude(base=fixtures_dir / "pep_561_stub_only", include="bad")

assert str(e.value) == "bad is not a package."

0 comments on commit 7809999

Please sign in to comment.