|
4 | 4 | from hatch.env.plugin.interface import EnvironmentInterface |
5 | 5 | from hatch.project.core import Project |
6 | 6 | from hatch.utils.structures import EnvVars |
| 7 | +from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT |
7 | 8 |
|
8 | 9 |
|
9 | 10 | class MockEnvironment(EnvironmentInterface): # no cov |
@@ -636,14 +637,31 @@ def test_full_dev_mode(self, isolation, isolated_data_dir, platform): |
636 | 637 |
|
637 | 638 | assert environment.dependencies == ['dep2', 'dep3'] |
638 | 639 |
|
639 | | - def test_unknown_dynamic_feature(self, isolation, isolated_data_dir, platform): |
| 640 | + def test_unknown_dynamic_feature(self, helpers, temp_dir, isolated_data_dir, platform): |
640 | 641 | config = { |
641 | 642 | 'project': {'name': 'my_app', 'version': '0.0.1', 'dynamic': ['optional-dependencies']}, |
642 | | - 'tool': {'hatch': {'envs': {'default': {'skip-install': False, 'features': ['foo']}}}}, |
| 643 | + 'tool': { |
| 644 | + 'hatch': { |
| 645 | + 'metadata': {'hooks': {'custom': {}}}, |
| 646 | + 'envs': {'default': {'skip-install': False, 'features': ['foo']}}, |
| 647 | + }, |
| 648 | + }, |
643 | 649 | } |
644 | | - project = Project(isolation, config=config) |
| 650 | + project = Project(temp_dir, config=config) |
645 | 651 | environment = MockEnvironment( |
646 | | - isolation, project.metadata, 'default', project.config.envs['default'], {}, isolated_data_dir, platform, 0 |
| 652 | + temp_dir, project.metadata, 'default', project.config.envs['default'], {}, isolated_data_dir, platform, 0 |
| 653 | + ) |
| 654 | + |
| 655 | + build_script = temp_dir / DEFAULT_BUILD_SCRIPT |
| 656 | + build_script.write_text( |
| 657 | + helpers.dedent( |
| 658 | + """ |
| 659 | + from hatchling.metadata.plugin.interface import MetadataHookInterface |
| 660 | + class CustomHook(MetadataHookInterface): |
| 661 | + def update(self, metadata): |
| 662 | + metadata['optional-dependencies'] = {'bar': ['binary']} |
| 663 | + """ |
| 664 | + ) |
647 | 665 | ) |
648 | 666 |
|
649 | 667 | with pytest.raises( |
|
0 commit comments