|
11 | 11 |
|
12 | 12 |
|
13 | 13 | @pytest.mark.requires_internet |
14 | | -def test_other_backend(hatch, temp_dir, helpers): |
15 | | - project_name = 'My.App' |
| 14 | +class TestOtherBackend: |
| 15 | + def test_standard(self, hatch, temp_dir, helpers): |
| 16 | + project_name = 'My.App' |
16 | 17 |
|
17 | | - with temp_dir.as_cwd(): |
18 | | - result = hatch('new', project_name) |
19 | | - assert result.exit_code == 0, result.output |
| 18 | + with temp_dir.as_cwd(): |
| 19 | + result = hatch('new', project_name) |
| 20 | + assert result.exit_code == 0, result.output |
20 | 21 |
|
21 | | - path = temp_dir / 'my-app' |
22 | | - data_path = temp_dir / 'data' |
23 | | - data_path.mkdir() |
| 22 | + path = temp_dir / 'my-app' |
| 23 | + data_path = temp_dir / 'data' |
| 24 | + data_path.mkdir() |
24 | 25 |
|
25 | | - project = Project(path) |
26 | | - config = dict(project.raw_config) |
27 | | - config['build-system']['requires'] = ['flit-core'] |
28 | | - config['build-system']['build-backend'] = 'flit_core.buildapi' |
29 | | - config['project']['version'] = '0.0.1' |
30 | | - config['project']['dynamic'] = [] |
31 | | - del config['project']['license'] |
32 | | - project.save_config(config) |
| 26 | + project = Project(path) |
| 27 | + config = dict(project.raw_config) |
| 28 | + config['build-system']['requires'] = ['flit-core'] |
| 29 | + config['build-system']['build-backend'] = 'flit_core.buildapi' |
| 30 | + config['project']['version'] = '0.0.1' |
| 31 | + config['project']['dynamic'] = [] |
| 32 | + del config['project']['license'] |
| 33 | + project.save_config(config) |
33 | 34 |
|
34 | | - build_directory = path / 'dist' |
35 | | - assert not build_directory.is_dir() |
| 35 | + build_directory = path / 'dist' |
| 36 | + assert not build_directory.is_dir() |
36 | 37 |
|
37 | | - with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
38 | | - result = hatch('build') |
| 38 | + with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
| 39 | + result = hatch('build') |
39 | 40 |
|
40 | | - assert result.exit_code == 0, result.output |
41 | | - assert result.output == helpers.dedent( |
42 | | - """ |
43 | | - Creating environment: build |
44 | | - Checking dependencies |
45 | | - Syncing dependencies |
46 | | - """ |
47 | | - ) |
| 41 | + assert result.exit_code == 0, result.output |
| 42 | + assert result.output == helpers.dedent( |
| 43 | + """ |
| 44 | + Creating environment: build |
| 45 | + Checking dependencies |
| 46 | + Syncing dependencies |
| 47 | + """ |
| 48 | + ) |
48 | 49 |
|
49 | | - assert build_directory.is_dir() |
50 | | - assert (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
51 | | - assert (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
| 50 | + assert build_directory.is_dir() |
| 51 | + assert (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
| 52 | + assert (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
52 | 53 |
|
53 | | - build_directory.remove() |
54 | | - with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
55 | | - result = hatch('build', '-t', 'wheel') |
| 54 | + build_directory.remove() |
| 55 | + with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
| 56 | + result = hatch('build', '-t', 'wheel') |
56 | 57 |
|
57 | | - assert result.exit_code == 0, result.output |
58 | | - assert not result.output |
| 58 | + assert result.exit_code == 0, result.output |
| 59 | + assert not result.output |
59 | 60 |
|
60 | | - assert build_directory.is_dir() |
61 | | - assert (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
62 | | - assert not (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
| 61 | + assert build_directory.is_dir() |
| 62 | + assert (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
| 63 | + assert not (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
63 | 64 |
|
64 | | - build_directory.remove() |
65 | | - with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
66 | | - result = hatch('build', '-t', 'sdist') |
| 65 | + build_directory.remove() |
| 66 | + with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
| 67 | + result = hatch('build', '-t', 'sdist') |
67 | 68 |
|
68 | | - assert result.exit_code == 0, result.output |
69 | | - assert not result.output |
| 69 | + assert result.exit_code == 0, result.output |
| 70 | + assert not result.output |
| 71 | + |
| 72 | + assert build_directory.is_dir() |
| 73 | + assert not (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
| 74 | + assert (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
| 75 | + |
| 76 | + def test_legacy(self, hatch, temp_dir, helpers): |
| 77 | + path = temp_dir / 'tmp' |
| 78 | + path.mkdir() |
| 79 | + data_path = temp_dir / 'data' |
| 80 | + data_path.mkdir() |
| 81 | + |
| 82 | + (path / 'pyproject.toml').write_text( |
| 83 | + """\ |
| 84 | +[build-system] |
| 85 | +requires = ["setuptools"] |
| 86 | +build-backend = "setuptools.build_meta" |
| 87 | +""" |
| 88 | + ) |
| 89 | + (path / 'setup.py').write_text( |
| 90 | + """\ |
| 91 | +import setuptools |
| 92 | +setuptools.setup(name="tmp", version="0.0.1") |
| 93 | +""" |
| 94 | + ) |
| 95 | + (path / 'tmp.py').write_text( |
| 96 | + """\ |
| 97 | +print("Hello World!") |
| 98 | +""" |
| 99 | + ) |
70 | 100 |
|
71 | | - assert build_directory.is_dir() |
72 | | - assert not (build_directory / 'my_app-0.0.1-py3-none-any.whl').is_file() |
73 | | - assert (build_directory / 'my_app-0.0.1.tar.gz').is_file() |
| 101 | + build_directory = path / 'dist' |
| 102 | + assert not build_directory.is_dir() |
| 103 | + |
| 104 | + with path.as_cwd(env_vars={ConfigEnvVars.DATA: str(data_path)}): |
| 105 | + result = hatch('build') |
| 106 | + |
| 107 | + assert result.exit_code == 0, result.output |
| 108 | + assert result.output == helpers.dedent( |
| 109 | + """ |
| 110 | + Creating environment: build |
| 111 | + Checking dependencies |
| 112 | + Syncing dependencies |
| 113 | + """ |
| 114 | + ) |
| 115 | + |
| 116 | + assert build_directory.is_dir() |
| 117 | + assert (build_directory / 'tmp-0.0.1-py3-none-any.whl').is_file() |
| 118 | + assert (build_directory / 'tmp-0.0.1.tar.gz').is_file() |
74 | 119 |
|
75 | 120 |
|
76 | 121 | @pytest.mark.allow_backend_process |
|
0 commit comments