mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 14:50:19 +00:00
b3c7252197
## About - Add Ruff configuration to `pyproject.toml`, apply its formatter, and satisfy its linter. - Migrate pytest configuration to `pyproject.toml`.
56 lines
877 B
Python
56 lines
877 B
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
import responder
|
|
|
|
|
|
@pytest.fixture
|
|
def data_dir(current_dir):
|
|
yield current_dir / "data"
|
|
|
|
|
|
@pytest.fixture()
|
|
def current_dir():
|
|
yield Path(__file__).parent
|
|
|
|
|
|
@pytest.fixture
|
|
def api():
|
|
return responder.API(debug=False, allowed_hosts=[";"])
|
|
|
|
|
|
@pytest.fixture
|
|
def session(api):
|
|
return api.requests
|
|
|
|
|
|
@pytest.fixture
|
|
def url():
|
|
def url_for(s):
|
|
return f"http://;{s}"
|
|
|
|
return url_for
|
|
|
|
|
|
@pytest.fixture
|
|
def flask():
|
|
from flask import Flask
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def hello():
|
|
return "Hello World!"
|
|
|
|
return app
|
|
|
|
|
|
@pytest.fixture
|
|
def template_path(tmpdir):
|
|
# create a Jinja template file on the filesystem
|
|
template_name = "test.html"
|
|
template_file = tmpdir.mkdir("static").join(template_name)
|
|
template_file.write("{{ var }}")
|
|
return template_file
|