-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make requirements.txt for extensions optional
There are multiple ways within python to declare dependencies (eg. via pyproject.toml, setup.py or setup.cfg). Requiring a requirements.txt file in a specific path doesn't work for a lot of projects out there so make the requirements.txt file optional.
- Loading branch information
Showing
7 changed files
with
15 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,41 +308,6 @@ def test_flask_extension_bare(tmp_path): | |
} | ||
|
||
|
||
@pytest.mark.usefixtures("flask_extension") | ||
def test_flask_extension_no_requirements_txt_error(tmp_path): | ||
(tmp_path / "app.py").write_text("app = object()") | ||
flask_input_yaml = { | ||
"extensions": ["flask-framework"], | ||
"base": "bare", | ||
"build-base": "[email protected]", | ||
"platforms": {"amd64": {}}, | ||
} | ||
with pytest.raises(ExtensionError) as exc: | ||
extensions.apply_extensions(tmp_path, flask_input_yaml) | ||
assert ( | ||
str(exc.value) | ||
== "- missing a requirements.txt file. The flask-framework extension requires this file with 'flask' specified as a dependency." | ||
) | ||
|
||
|
||
@pytest.mark.usefixtures("flask_extension") | ||
def test_flask_extension_requirements_txt_no_flask_error(tmp_path): | ||
(tmp_path / "app.py").write_text("app = object()") | ||
(tmp_path / "requirements.txt").write_text("") | ||
flask_input_yaml = { | ||
"extensions": ["flask-framework"], | ||
"base": "bare", | ||
"build-base": "[email protected]", | ||
"platforms": {"amd64": {}}, | ||
} | ||
with pytest.raises(ExtensionError) as exc: | ||
extensions.apply_extensions(tmp_path, flask_input_yaml) | ||
|
||
assert ( | ||
str(exc.value) == "- missing flask package dependency in requirements.txt file." | ||
) | ||
|
||
|
||
@pytest.mark.usefixtures("flask_extension") | ||
def test_flask_extension_bad_app_py(tmp_path): | ||
bad_code = textwrap.dedent( | ||
|
@@ -382,7 +347,6 @@ def test_flask_extension_no_requirements_txt_no_app_py_error(tmp_path): | |
with pytest.raises(ExtensionError) as exc: | ||
extensions.apply_extensions(tmp_path, flask_input_yaml) | ||
assert str(exc.value) == ( | ||
"- missing a requirements.txt file. The flask-framework extension requires this file with 'flask' specified as a dependency.\n" | ||
"- flask application can not be imported from app:app, no app.py file found in the project root." | ||
) | ||
|
||
|