repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
hatch | tests/config/test_model.py | .py | import subprocess
import pytest
from hatch.config.model import ConfigurationError, RootConfig
def test_default(default_cache_dir, default_data_dir):
config = RootConfig({})
config.parse_fields()
assert config.raw_data == {
"mode": "local",
"project": "",
"shell": "",
"di... | 1,468 | 44,352 |
hatch | tests/utils/test_fs.py | .py | import os
import pathlib
from hatch.utils.fs import Path, temp_chdir, temp_directory
class TestPath:
def test_type(self):
expected_type = type(pathlib.Path())
assert isinstance(Path(), expected_type)
assert issubclass(Path, expected_type)
def test_resolve_relative_non_existent(self,... | 130 | 3,463 |
hatch | tests/utils/test_auth.py | .py | from hatch.publish.auth import AuthenticationCredentials
from hatch.utils.fs import Path
def test_pypirc(tmp_path, mocker):
# Create a fake home directory
fake_home = tmp_path / "home"
fake_home.mkdir()
# Create .pypirc in the fake home
pypirc = fake_home / ".pypirc"
pypirc.write_text("""\
[o... | 49 | 1,278 |
hatch | tests/utils/test_runner.py | .py | from __future__ import annotations
import pytest
from hatch.utils.runner import parse_matrix_variables, select_environments
class TestParseMatrixVariables:
def test_empty(self):
assert parse_matrix_variables(()) == {}
def test_single(self):
assert parse_matrix_variables(("py=3.9",)) == {"py... | 101 | 4,067 |
hatch | tests/utils/test_linehaul.py | .py | import json
import platform
import pytest
from hatch._version import __version__
from hatch.utils.linehaul import get_linehaul_component, get_linehaul_data
class TestGetLinehaulData:
def test_installer_info(self):
data = get_linehaul_data()
assert data["installer"]["name"] == "hatch"
as... | 166 | 4,730 |
hatch | tests/utils/test_structures.py | .py | import os
from hatch.utils.structures import EnvVars
def get_random_name():
return os.urandom(16).hex().upper()
class TestEnvVars:
def test_restoration(self):
num_env_vars = len(os.environ)
with EnvVars():
os.environ.clear()
assert len(os.environ) == num_env_vars
d... | 62 | 1,698 |
hatch | tests/utils/test_platform.py | .py | import os
import stat
import pytest
from hatch.utils.fs import Path
from hatch.utils.platform import Platform
from hatch.utils.structures import EnvVars
@pytest.mark.requires_windows
class TestWindows:
def test_tag(self):
assert Platform().windows is True
def test_default_shell(self):
asser... | 123 | 4,187 |
hatch | tests/cli/test_root.py | .py | import os
from hatch.config.constants import ConfigEnvVars
from hatch.config.user import ConfigFile
from hatch.utils.structures import EnvVars
class TestFreshInstallation:
INSTALL_MESSAGE = """\
No config file found, creating one with default settings now...
Success! Please see `hatch config`.
"""
def test_... | 42 | 1,328 |
hatch | tests/cli/fmt/test_fmt.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
FMT_DEPRECATION_WARNING = (
"The `hatch fmt` command is deprecated and will be removed in a future release."
" Use `hatch check code --fix` for linting and `hatch check fmt... | 975 | 34,295 |
hatch | tests/cli/new/test_new.py | .py | import pytest
from hatch.config.constants import ConfigEnvVars
def remove_trailing_spaces(text):
return "".join(f"{line.rstrip()}\n" for line in text.splitlines(True))
class TestErrors:
def test_path_is_file(self, hatch, temp_dir):
with temp_dir.as_cwd():
path = temp_dir / "foo"
... | 638 | 17,491 |
hatch | tests/cli/publish/test_publish.py | .py | import os
import secrets
import tarfile
import zipfile
from collections import defaultdict
import pytest
from hatch.config.constants import PublishEnvVars
pytestmark = [
pytest.mark.requires_docker,
pytest.mark.requires_internet,
pytest.mark.usefixtures("devpi"),
pytest.mark.usefixtures("mock_backend... | 710 | 23,542 |
hatch | tests/cli/project/test_metadata.py | .py | import os
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
pytestmark = [pytest.mark.usefixtures("mock_backend_process_output")]
def read_readme(project_dir):
return repr((project_dir / "README.txt").... | 427 | 13,318 |
hatch | tests/cli/check/test_check_group.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
class TestNoSubcommand:
"""Tests that `hatch check` with no subcommand runs all checks."""
def test_runs_all_checks(self, hatch, temp_dir, config_file, env_run):
config_file.model.template.plugins["def... | 139 | 5,149 |
hatch | tests/cli/check/test_check_fmt.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
def construct_ruff_defaults_file(rules: tuple[str, ...]) -> str:
from hatch.cli.fmt.core import PER_FILE_IGNORED_RULES
lines = [
"line-length = 120",
"",
... | 375 | 13,068 |
hatch | tests/cli/check/test_check_code.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
def construct_ruff_defaults_file(rules: tuple[str, ...]) -> str:
from hatch.cli.fmt.core import PER_FILE_IGNORED_RULES
lines = [
"line-length = 120",
"",
... | 461 | 15,788 |
hatch | tests/cli/check/test_check_types.py | .py | from __future__ import annotations
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.utils.toml import load_toml_data
class TestDefaults:
def test_check(self, hatch, temp_dir, config_file, env_run):
config_file.model.template.plugins["default"]["tests"] = False
config_fil... | 207 | 6,955 |
hatch | tests/cli/status/test_status.py | .py | import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.utils.fs import temp_chdir
from hatch.utils.structures import EnvVars
class TestModeLocalDefault:
def test_no_project(self, hatch, isolation, config_file, helpers):
result = hatch("status")
assert result.exit_code == 0, re... | 272 | 8,727 |
hatch | tests/cli/dep/test_dep_lock.py | .py | from contextlib import contextmanager
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.env.virtual import VirtualEnvironment
from hatch.project.core import Project
from hatch.utils.toml import load_toml_file
@pytest.mark.usefixtures("mock_locker")
def test_dep_lock_export(hatch, helpers, te... | 251 | 7,994 |
hatch | tests/cli/dep/test_hash.py | .py | import os
from hashlib import sha256
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_incompatible_environment(hatch, temp_dir, helpers, build_env_config):
project_name = "My.App"
with temp_dir.as_cwd()... | 132 | 3,849 |
hatch | tests/cli/dep/show/test_requirements.py | .py | import os
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_incompatible_environment(hatch, temp_dir, helpers, build_env_config):
project_name = "My.App"
with temp_dir.as_cwd():
result = hatch("n... | 270 | 7,621 |
hatch | tests/cli/dep/show/test_table.py | .py | import os
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
@pytest.fixture(scope="module", autouse=True)
def _terminal_width():
with EnvVars({"COLUMNS": "200"... | 264 | 8,128 |
hatch | tests/cli/dep/show/test_sources.py | .py | import pytest
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
@pytest.fixture(scope="module", autouse=True)
def _terminal_width():
with EnvVars({"COLUMNS": "200"}):
yield
def test_no_sources(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins... | 92 | 2,818 |
hatch | tests/cli/self/test_report.py | .py | import os
import sys
from textwrap import indent
from urllib.parse import unquote_plus
import pytest
from hatch._version import __version__
from hatch.utils.structures import EnvVars
URL = "https://github.com/pypa/hatch/issues/new?body="
STATIC_BODY = """\
## Current behavior
<!-- A clear and concise description of ... | 288 | 6,108 |
hatch | tests/cli/self/test_self.py | .py | import os
def test(hatch):
result = hatch(os.environ["PYAPP_COMMAND_NAME"], "-h")
assert result.exit_code == 0, result.output
| 8 | 137 |
hatch | tests/cli/clean/test_clean.py | .py | import os
import pytest
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT, DEFAULT_CONFIG_FILE
pytestmark = [pytest.mark.usefixtures("mock_backend_process")]
@pytest.mark.requires_internet
def test(hatch, temp_dir, helpers, config_file, mock_plugin_installation):
... | 88 | 2,565 |
hatch | tests/cli/python/test_update.py | .py | def test_not_installed(hatch, helpers):
result = hatch("python", "update", "3.9", "3.10")
assert result.exit_code == 1, result.output
assert result.output == helpers.dedent(
"""
Distributions not installed: 3.9, 3.10
"""
)
def test_basic(hatch, helpers, temp_dir_data, path_app... | 91 | 3,151 |
hatch | tests/cli/python/test_remove.py | .py | def test_not_installed(hatch, helpers):
result = hatch("python", "remove", "3.9", "3.10")
assert result.exit_code == 0, result.output
assert result.output == helpers.dedent(
"""
Distribution is not installed: 3.9
Distribution is not installed: 3.10
"""
)
def test_basic... | 61 | 1,741 |
hatch | tests/cli/python/test_show.py | .py | from rich.box import ASCII_DOUBLE_HEAD
from rich.console import Console
from rich.table import Table
from hatch.python.resolve import get_compatible_distributions
def render_table(title, rows):
console = Console(force_terminal=False, no_color=True, legacy_windows=False)
table = Table(title=title, show_lines=... | 140 | 4,474 |
hatch | tests/cli/python/test_find.py | .py | def test_not_installed(hatch, helpers):
name = "3.10"
result = hatch("python", "find", name)
assert result.exit_code == 1, result.output
assert result.output == helpers.dedent(
f"""
Distribution not installed: {name}
"""
)
def test_binary(hatch, helpers, temp_dir_data, dis... | 39 | 1,039 |
hatch | tests/cli/python/test_install.py | .py | import json
import secrets
import pytest
from hatch.errors import PythonDistributionResolutionError
from hatch.python.core import InstalledDistribution
from hatch.python.distributions import ORDERED_DISTRIBUTIONS
from hatch.python.resolve import get_distribution
def test_unknown(hatch, helpers, path_append, mocker)... | 291 | 10,226 |
hatch | tests/cli/python/conftest.py | .py | import secrets
import pytest
from hatch.utils.shells import detect_shell
@pytest.fixture(autouse=True)
def default_shells(platform):
return [] if platform.windows else [detect_shell(platform)[0]]
@pytest.fixture(autouse=True)
def isolated_python_directory(config_file):
config_file.model.dirs.python = "iso... | 33 | 769 |
hatch | tests/cli/version/test_version.py | .py | import os
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
class TestNoProject:
def test_random_directory(self, hatch, temp_dir, helpers):
with temp_dir.as_cwd():
result = hatch("ve... | 463 | 13,676 |
hatch | tests/cli/config/test_explore.py | .py | def test_call(hatch, config_file, mocker):
mock = mocker.patch("click.launch")
result = hatch("config", "explore")
assert result.exit_code == 0, result.output
mock.assert_called_once_with(str(config_file.path), locate=True)
| 7 | 241 |
hatch | tests/cli/config/test_show.py | .py | def test_default_scrubbed(hatch, config_file, helpers, default_cache_dir, default_data_dir):
config_file.model.project = "foo"
config_file.model.publish["index"]["auth"] = "bar"
config_file.save()
result = hatch("config", "show")
default_cache_directory = str(default_cache_dir).replace("\\", "\\\\... | 111 | 2,644 |
hatch | tests/cli/config/test_find.py | .py | def test(hatch, config_file, helpers):
result = hatch("config", "find")
assert result.exit_code == 0, result.output
assert result.output == helpers.dedent(
f"""
{config_file.path}
"""
)
| 10 | 227 |
hatch | tests/cli/config/test_set.py | .py | def test_standard(hatch, config_file, helpers):
result = hatch("config", "set", "project", "foo")
assert result.exit_code == 0, result.output
assert result.output == helpers.dedent(
"""
New setting:
project = "foo"
"""
)
config_file.load()
assert config_file.mod... | 252 | 6,516 |
hatch | tests/cli/config/test_restore.py | .py | def test_standard(hatch, config_file):
config_file.model.project = "foo"
config_file.save()
result = hatch("config", "restore")
assert result.exit_code == 0, result.output
assert result.output == "Settings were successfully restored.\n"
config_file.load()
assert config_file.model.project ... | 26 | 660 |
hatch | tests/cli/test/test_test.py | .py | from __future__ import annotations
import sys
import pytest
from hatch.config.constants import ConfigEnvVars
from hatch.env.utils import get_env_var
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
@pytest.fixture(scope="module", autouse=True)
def _terminal_width():
with EnvVar... | 1,200 | 42,889 |
hatch | tests/cli/env/test_prune.py | .py | import os
from hatch.config.constants import AppEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_unknown_type(hatch, helpers, temp_dir_data, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()
pr... | 181 | 5,006 |
hatch | tests/cli/env/test_remove.py | .py | import os
from hatch.config.constants import AppEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_unknown(hatch, temp_dir_data, helpers):
project_name = "My.App"
with temp_dir_data.as_cwd():
result = hatch("new", project_name)
asse... | 451 | 12,629 |
hatch | tests/cli/env/test_run.py | .py | import os
from hatch.config.constants import ConfigEnvVars
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_filter_not_mapping(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()
... | 309 | 9,220 |
hatch | tests/cli/env/test_create.py | .py | import os
import sys
import pytest
from hatch.config.constants import AppEnvVars, ConfigEnvVars
from hatch.env.utils import get_env_var
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
from hatch.venv.core import UVVirtualEnv, VirtualEnv
from hatchling.utils.constants import DEFAULT_B... | 2,180 | 67,864 |
hatch | tests/cli/env/test_show.py | .py | import json
import os
import pytest
from hatch.env.utils import get_env_var
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
@pytest.fixture(scope="module", autouse=True)
def _terminal_width():
with EnvVars({"COLUMNS": "2... | 511 | 18,892 |
hatch | tests/cli/env/test_find.py | .py | import os
import sys
import pytest
from hatch.project.core import Project
from hatchling.utils.constants import DEFAULT_CONFIG_FILE
def test_undefined(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()
project_name = "My.App"
w... | 238 | 6,487 |
hatch | tests/cli/env/test_lock.py | .py | import os
import pytest
import tomli_w
from hatch.config.constants import ConfigEnvVars
from hatch.env.lockers.uv import UvLocker
from hatch.project.core import Project
from hatch.utils.toml import load_toml_file
def _require_uv(uv_on_path: str | None) -> None:
if not uv_on_path:
pytest.skip("uv not fou... | 1,196 | 38,987 |
hatch | tests/cli/run/test_run.py | .py | import os
import signal
import sys
import sysconfig
import pytest
from hatch.config.constants import AppEnvVars, ConfigEnvVars
from hatch.project.core import Project
from hatch.python.core import PythonManager
from hatch.python.resolve import get_compatible_distributions, is_valid_distribution_name
from hatch.utils.f... | 2,677 | 84,150 |
hatch | tests/backend/test_build.py | .py | from hatchling.build import build_editable, build_sdist, build_wheel
def test_sdist(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["src-layout"] = False
config_file.save()
project_name = "My.App"
with temp_dir.as_cwd():
result = hatch("new", project_nam... | 125 | 3,336 |
hatch | tests/backend/builders/utils.py | .py | from hatchling.builders.plugin.interface import BuilderInterface
class MockBuilder(BuilderInterface): # no cov
def get_version_api(self):
return {}
| 7 | 163 |
hatch | tests/backend/builders/test_config.py | .py | import os
import re
from os.path import join as pjoin
import pathspec
import pytest
from hatch.utils.structures import EnvVars
from hatchling.builders.constants import BuildEnvVars
from .utils import MockBuilder
class TestDirectory:
def test_default(self, isolation):
builder = MockBuilder(str(isolation... | 2,070 | 89,203 |
hatch | tests/backend/builders/test_custom.py | .py | import re
import zipfile
import pytest
from hatchling.builders.custom import CustomBuilder
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
def test_target_config_not_table(isolation):
config = {"tool": {"hatch": {"build": {"targets": {"custom": 9000}}}}}
with pytest.raises(TypeError, match="Fiel... | 344 | 10,647 |
hatch | tests/backend/builders/test_wheel.py | .py | from __future__ import annotations
import os
import platform
import sys
import zipfile
from typing import TYPE_CHECKING
import packaging.tags
import pytest
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.builders.utils import get_known_python_major_versions
from hatchling.builders.whe... | 4,029 | 151,467 |
hatch | tests/backend/builders/test_sdist.py | .py | import os
import tarfile
import pytest
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.builders.sdist import SdistBuilder
from hatchling.builders.utils import get_reproducible_timestamp
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION, get_core_metadata_constructors
from ha... | 1,545 | 55,800 |
hatch | tests/backend/builders/test_binary.py | .py | from __future__ import annotations
import os
import subprocess
import sys
from typing import Any
import pytest
from hatch.utils.fs import Path
from hatch.utils.structures import EnvVars
from hatchling.builders.app import AppBuilder
from hatchling.builders.binary import BinaryBuilder
from hatchling.builders.plugin.in... | 730 | 25,679 |
hatch | tests/backend/builders/hooks/test_version.py | .py | import pytest
from hatchling.builders.hooks.version import VersionBuildHook
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
class TestConfigPath:
def test_correct(self, isolation):
config = {... | 266 | 8,966 |
hatch | tests/backend/builders/hooks/test_custom.py | .py | import re
import pytest
from hatchling.builders.hooks.custom import CustomBuildHook
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
def test_no_path(isolation):
config = {"path": ""}
with pytest.raises(ValueError, match="Option `path` for build hook `custom` must not be empty if defined"):
... | 104 | 2,886 |
hatch | tests/backend/builders/plugin/test_interface.py | .py | from os.path import sep as path_sep
import pytest
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, EXCLUDED_FILES
from hatchling.metadata.core import ProjectMetadata
from hatchling.plugin.manager import PluginManager
from ..utils import MockBuilder
class TestClean:
def test_default(self, isolatio... | 390 | 14,906 |
hatch | tests/backend/metadata/test_core.py | .py | import pytest
from hatchling.metadata.core import BuildMetadata, CoreMetadata, HatchMetadata, ProjectMetadata
from hatchling.metadata.spec import (
LATEST_METADATA_VERSION,
get_core_metadata_constructors,
project_metadata_from_core_metadata,
)
from hatchling.plugin.manager import PluginManager
from hatchli... | 1,888 | 75,981 |
hatch | tests/backend/metadata/test_build.py | .py | import pytest
from packaging.requirements import Requirement
from hatchling.metadata.core import BuildMetadata
class TestRequires:
def test_default(self, isolation):
metadata = BuildMetadata(str(isolation), {})
assert metadata.requires == metadata.requires == []
def test_not_array(self, iso... | 83 | 3,081 |
hatch | tests/backend/metadata/test_hatch.py | .py | import pytest
from hatchling.metadata.core import HatchMetadata
from hatchling.plugin.manager import PluginManager
from hatchling.version.scheme.standard import StandardScheme
from hatchling.version.source.regex import RegexSource
class TestBuildConfig:
def test_default(self, isolation):
config = {}
... | 180 | 7,131 |
hatch | tests/backend/metadata/test_custom_hook.py | .py | import re
import pytest
from hatchling.metadata.custom import CustomMetadataHook
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
def test_no_path(isolation):
config = {"path": ""}
with pytest.raises(ValueError, match="Option `path` for metadata hook `custom` must not be empty if defined"):
... | 110 | 2,927 |
hatch | tests/backend/metadata/test_spec.py | .py | import pytest
from hatchling.metadata.core import ProjectMetadata
from hatchling.metadata.spec import (
LATEST_METADATA_VERSION,
get_core_metadata_constructors,
project_metadata_from_core_metadata,
)
class TestProjectMetadataFromCoreMetadata:
def test_missing_name(self):
core_metadata = f"""\... | 2,555 | 83,467 |
hatch | tests/backend/version/scheme/test_standard.py | .py | import pytest
from packaging.version import _parse_letter_version # noqa: PLC2701
from hatch.utils.structures import EnvVars
from hatchling.utils.constants import VersionEnvVars
from hatchling.version.scheme.standard import StandardScheme
def test_not_higher(isolation):
scheme = StandardScheme(str(isolation), {... | 149 | 5,092 |
hatch | tests/backend/version/source/test_code.py | .py | import pytest
from hatchling.version.source.code import CodeSource
def test_no_path(isolation):
source = CodeSource(str(isolation), {})
with pytest.raises(ValueError, match="option `path` must be specified"):
source.get_version_data()
def test_path_not_string(isolation):
source = CodeSource(st... | 128 | 3,696 |
hatch | tests/backend/version/source/test_regex.py | .py | from itertools import product
import pytest
from hatchling.version.source.regex import RegexSource
DEFAULT_PATTERN_PRODUCTS = list(product(("__version__", "VERSION", "version"), ('"', "'"), ("", "v")))
def test_no_path(isolation):
source = RegexSource(str(isolation), {})
with pytest.raises(ValueError, mat... | 120 | 3,603 |
hatch | tests/backend/version/source/test_env.py | .py | import pytest
from hatch.utils.structures import EnvVars
from hatchling.version.source.env import EnvSource
def test_no_variable(isolation):
source = EnvSource(str(isolation), {})
with pytest.raises(ValueError, match="option `variable` must be specified"):
source.get_version_data()
def test_variab... | 36 | 1,042 |
hatch | tests/backend/utils/test_fs.py | .py | import os
from hatchling.utils.fs import path_to_uri
class TestPathToURI:
def test_unix(self, isolation, uri_slash_prefix):
bad_path = f"{isolation}{os.sep}"
normalized_path = str(isolation).replace(os.sep, "/")
assert path_to_uri(bad_path) == f"file:{uri_slash_prefix}{normalized_path}"
... | 16 | 580 |
hatch | tests/backend/utils/test_macos.py | .py | from __future__ import annotations
import platform
import pytest
from hatchling.builders.macos import normalize_macos_version, process_macos_plat_tag
@pytest.mark.parametrize(
("plat", "arch", "compat", "archflags", "deptarget", "expected"),
[
("macosx_10_9_x86_64", "x86_64", False, "", "", "macosx... | 57 | 2,185 |
hatch | tests/backend/utils/test_context.py | .py | import os
import pytest
from hatch.utils.structures import EnvVars
from hatchling.utils.context import Context
def test_normal(isolation):
context = Context(isolation)
assert context.format("foo {0} {key}", "arg", key="value") == "foo arg value"
class TestStatic:
def test_directory_separator(self, iso... | 142 | 5,356 |
hatch | tests/env/collectors/test_custom.py | .py | import re
import pytest
from hatch.env.collectors.custom import CustomEnvironmentCollector
from hatch.plugin.constants import DEFAULT_CUSTOM_SCRIPT
def test_no_path(isolation):
config = {"path": ""}
with pytest.raises(
ValueError, match="Option `path` for environment collector `custom` must not be ... | 106 | 2,934 |
hatch | tests/env/plugin/test_interface.py | .py | import re
import pytest
from hatch.config.constants import AppEnvVars
from hatch.env.plugin.interface import EnvironmentInterface
from hatch.project.core import Project
from hatch.utils.structures import EnvVars
class MockEnvironment(EnvironmentInterface): # no cov
PLUGIN_NAME = "mock"
def find(self):
... | 4,532 | 152,955 |
hatch | tests/helpers/helpers.py | .py | from __future__ import annotations
import importlib
import json
import os
import re
import sys
from datetime import datetime, timezone
from functools import lru_cache
from textwrap import dedent as _dedent
from typing import TYPE_CHECKING
from unittest.mock import call
import tomli_w
from hatch.config.user import Ro... | 185 | 6,358 |
hatch | tests/helpers/templates/sdist/standard_default_vcs_git_exclusion_files.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = [File(Path(relative_root, f.pa... | 34 | 812 |
hatch | tests/helpers/templates/sdist/standard_default_build_script_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("rela... | 50 | 1,319 |
hatch | tests/helpers/templates/sdist/standard_default_vcs_mercurial_exclusion_files.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = [File(Path(relative_root, f.pa... | 40 | 861 |
hatch | tests/helpers/templates/sdist/standard_default.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = [File(Path(relative_root, f.pa... | 25 | 627 |
hatch | tests/helpers/templates/sdist/standard_include_config_file.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = []
for f in get_template_f... | 54 | 1,328 |
hatch | tests/helpers/templates/sdist/standard_default_build_script_artifacts.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("rela... | 48 | 1,245 |
hatch | tests/helpers/templates/sdist/standard_default_support_legacy.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = [File(Path(relative_root, f.pa... | 40 | 906 |
hatch | tests/helpers/templates/sdist/standard_include.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
def get_files(**kwargs):
relative_root = kwargs.get("relative_root", "")
files = []
for f in get_template_f... | 53 | 1,272 |
hatch | tests/helpers/templates/new/projects_urls_space_in_label.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"<copyright holders>", f"{kwargs['author']} <{kwar... | 133 | 3,727 |
hatch | tests/helpers/templates/new/feature_ci.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from .default import get_files as get_template_files
def get_files(**kwargs):
files = [File(Path(f.path), f.contents) for f in get_template_files(**kwargs)]
files.append(
File(
Path(".github", "workflows", "test.yml"),
... | 60 | 1,450 |
hatch | tests/helpers/templates/new/default.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
description = kwargs.get("description", "")
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"... | 135 | 3,782 |
hatch | tests/helpers/templates/new/feature_no_src_layout.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
description = kwargs.get("description", "")
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"... | 135 | 3,748 |
hatch | tests/helpers/templates/new/licenses_multiple.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT, Apache_2_0
def get_files(**kwargs):
return [
File(Path("LICENSES", "Apache-2.0.txt"), Apache_2_0),
File(
Path("LICENSES", "MIT.txt"),
MIT.replace("<year>", f"{kwargs['year']}-presen... | 138 | 3,982 |
hatch | tests/helpers/templates/new/feature_cli.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"<copyright holders>", f"{kwargs['author']} <{kwar... | 169 | 4,794 |
hatch | tests/helpers/templates/new/projects_urls_empty.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"<copyright holders>", f"{kwargs['author']} <{kwar... | 130 | 3,444 |
hatch | tests/helpers/templates/new/basic.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from ..licenses import MIT
def get_files(**kwargs):
return [
File(
Path("LICENSE.txt"),
MIT.replace("<year>", f"{kwargs['year']}-present", 1).replace(
"<copyright holders>", f"{kwargs['author']} <{kwar... | 99 | 2,825 |
hatch | tests/helpers/templates/new/licenses_empty.py | .py | from hatch.template import File
from hatch.utils.fs import Path
def get_files(**kwargs):
return [
File(Path("src", kwargs["package_name"], "__init__.py")),
File(Path("src", kwargs["package_name"], "__about__.py"), '__version__ = "0.0.1"\n'),
File(Path("tests", "__init__.py")),
File... | 98 | 2,793 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_extra_dependencies.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 52 | 1,375 |
hatch | tests/helpers/templates/wheel/standard_default_symlink.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 51 | 1,357 |
hatch | tests/helpers/templates/wheel/standard_no_strict_naming.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,281 |
hatch | tests/helpers/templates/wheel/utils.py | .py | import hashlib
import os
import tempfile
from hatchling.builders.utils import format_file_hash, normalize_artifact_permissions
def update_record_file_contents(record_file, files, generated_files=()):
for template_file in sorted(
files,
key=lambda f: (
f.path.parts[0].endswith(".dist-i... | 61 | 1,933 |
hatch | tests/helpers/templates/wheel/standard_default_single_module.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 47 | 1,206 |
hatch | tests/helpers/templates/wheel/standard_editable_exact.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 58 | 1,732 |
hatch | tests/helpers/templates/wheel/standard_entry_points.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 58 | 1,432 |
hatch | tests/helpers/templates/wheel/standard_tests.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,296 |
hatch | tests/helpers/templates/wheel/standard_only_packages_artifact_override.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 53 | 1,393 |
hatch | tests/helpers/templates/wheel/standard_default_python_constraint.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 50 | 1,283 |
hatch | tests/helpers/templates/wheel/standard_default_build_script_force_include_no_duplication.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 51 | 1,371 |
hatch | tests/helpers/templates/wheel/standard_default_shared_data.py | .py | from hatch.template import File
from hatch.utils.fs import Path
from hatchling.__about__ import __version__
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION
from ..new.feature_no_src_layout import get_files as get_template_files
from .utils import update_record_file_contents
def get_files(**kwargs):
... | 53 | 1,493 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.