test_all

Comprehensive tests for check_dist.

Classes

Functions

_make_project(→ pathlib.Path)

Create a minimal hatch-based project for integration tests.

Module Contents

class test_all.TestTranslateExtension
test_no_change_on_native()

No translation when extension is already native.

test_so_to_pyd_on_windows(_mock)
test_dylib_to_dll_on_windows(_mock)
test_pyd_to_so_on_linux(_mock)
test_dll_to_so_on_linux(_mock)
test_pyd_to_so_on_darwin(_mock)
test_dll_to_dylib_on_darwin(_mock)
test_unrecognized_extension()
test_no_extension()
test_glob_pattern()

Glob patterns with extensions are also translated.

class test_all.TestMatchesPattern
test_exact_file()
test_directory_prefix()
test_directory_prefix_no_false_positive()
test_glob_star()
test_glob_full_path()
test_no_match()
test_basename_match()
test_cross_platform_extension(_mock)

On Windows, pattern *.so should match *.pyd.

test_question_mark_glob()
test_bracket_glob()
test_dotfile()
test_nested_directory_pattern()
class test_all.TestCheckPresent
FILES = ['check_dist/__init__.py', 'check_dist/_core.py', 'LICENSE', 'pyproject.toml', 'README.md']
test_all_present()
test_missing_pattern()
test_glob_present()
test_empty_patterns()
test_cross_platform_present(_mock)

Pattern ‘.so’ on Windows should look for ‘.pyd’.

test_cross_platform_missing(_mock)

Pattern ‘*.so’ on Windows should fail if no .pyd found.

class test_all.TestCheckAbsent
FILES = ['check_dist/__init__.py', 'Makefile', '.github/workflows/ci.yml', 'docs/index.md']
test_unwanted_present()
test_unwanted_directory()
test_all_clean()
test_empty_patterns()
test_docs_directory()
test_nested_in_present_pattern_skipped()

Files nested inside a ‘present’ dir are not flagged as absent.

test_present_patterns_none_flags_all()

Without present_patterns, nested files are still flagged.

class test_all.TestCheckWrongPlatformExtensions
test_so_on_windows(_mock)
test_pyd_on_linux(_mock)
test_clean_on_linux(_mock)
test_clean_on_darwin(_mock)
class test_all.TestCheckSdistVsVcs
test_matching()
test_extra_in_sdist()
test_missing_from_sdist()
test_generated_files_ignored()
test_egg_info_ignored()
test_hatch_packages_filter()

When hatch sdist packages are set, only those should be expected.

test_dotfiles_ignored_in_missing()
test_artifacts_not_flagged_as_extra()

Build artifacts (e.g. .so) should not be flagged as extra.

test_artifacts_in_sdist_section()

Artifacts listed in hatch sdist config should also be ignored.

test_only_include_vcs_check()

only-include config should scope the VCS comparison.

class test_all.TestMatchesHatchPattern
test_exact_file()
test_directory_prefix()
test_rooted_pattern()
test_no_match()
test_glob()
test_basename_match()
class test_all.TestSdistExpectedFiles

Covers hatch semantics: packages, include, exclude, only-include, force-include, sources, and their interactions.

VCS = ['pkg/__init__.py', 'pkg/core.py', 'rust/src/lib.rs', 'Cargo.toml', 'Cargo.lock',...
test_no_hatch_config()
test_only_include_exhaustive()
test_packages_acts_as_only_include()
test_packages_with_include()

packages + include: include is ignored (hatch treats packages as only-include, making the walk ‘explicit’).

test_include_filters_full_tree()
test_exclude_with_only_include()
test_exclude_with_packages()
test_exclude_with_no_constraints()
test_force_include_adds_files()
test_force_include_survives_exclude()
test_global_force_include_fallback()
test_target_force_include_overrides_global()
test_only_include_with_exclude()
test_empty_config()
class test_all.TestFilterExtrasByHatch

Verify that copier-derived extras are trimmed to match hatch config.

EXTRAS = ['rust', 'src', 'Cargo.toml', 'Cargo.lock', 'target']
test_no_hatch_config()
test_only_include_keeps_matching()
test_packages_clears_root_extras()

When only packages is set, non-package extras are removed.

test_packages_plus_include()

include is ignored when packages is set (explicit walk).

test_include_only()
test_force_include_destinations_kept()
test_empty_extras()
test_global_force_include()
class test_all.TestLoadConfig
test_missing_file(tmp_path)
test_valid_config(tmp_path)
test_partial_config(tmp_path)
test_no_check_dist_section(tmp_path)
class test_all.TestLoadHatchConfig
test_missing_file(tmp_path)
test_valid_config(tmp_path)
class test_all.TestModuleNameFromProject
test_spaces()
test_hyphens()
test_mixed()
test_no_change()
class test_all.TestNormalizeName
test_underscores()
test_hyphens()
test_periods()
test_mixed()
test_no_separators()
test_case_insensitive()
class test_all.TestResolveModuleFromHatch
test_wheel_packages_match()
test_sdist_packages_match()
test_no_match_returns_original()
test_empty_hatch_config()
test_exact_match_unchanged()
test_only_include_match()
test_top_level_packages()
test_period_variant()
class test_all.TestCopierDefaultsWithHatchModuleResolution
test_hatch_resolves_module_name()
test_no_hatch_uses_default_module()
class test_all.TestLoadCopierConfig
test_missing_file(tmp_path)
test_valid_file(tmp_path)
class test_all.TestCopierDefaults
test_cpp()
test_rust()
test_js()
test_unknown_extension()
test_no_extension()
test_no_project_name()
test_common_patterns_present()
class test_all.TestLoadConfigWithCopierFallback
test_no_check_dist_section_uses_copier(tmp_path)

When pyproject.toml has no [tool.check-dist], copier defaults apply.

test_explicit_config_takes_precedence(tmp_path)

When [tool.check-dist] exists, copier defaults are ignored.

test_no_copier_file_returns_empty(tmp_path)
class test_all.TestListSdistFiles
test_tar_gz(tmp_path)
test_zip(tmp_path)
test_unknown_format(tmp_path)
class test_all.TestListWheelFiles
test_wheel(tmp_path)
class test_all.TestFindDistFiles
test_finds_both(tmp_path)
test_finds_zip_sdist(tmp_path)
test_empty_dir(tmp_path)
test_nonexistent_dir(tmp_path)
class test_all.TestFindPreBuilt
test_finds_in_dist(tmp_path)
test_finds_in_wheelhouse(tmp_path)
test_prefers_dist_over_wheelhouse(tmp_path)
test_none_when_empty(tmp_path)
test_none_when_no_dirs(tmp_path)
class test_all.TestGetVcsFiles
test_in_git_repo(tmp_path)

Integration test: create a real tiny git repo.

test_all._make_project(tmp_path: pathlib.Path, *, extra_files: dict[str, str] | None = None) pathlib.Path

Create a minimal hatch-based project for integration tests.

class test_all.TestCheckDistIntegration
test_clean_project_passes(tmp_path)
test_missing_present_pattern(tmp_path)

A missing required file should cause failure.

test_verbose_lists_files(tmp_path)
class test_all.TestCLI
test_help()