feat: indie status page MVP -- FastAPI + SQLite
- 8 DB models (services, incidents, monitors, subscribers, etc.) - Full CRUD API for services, incidents, monitors - Public status page with live data - Incident detail page with timeline - API key authentication - Uptime monitoring scheduler - 13 tests passing - TECHNICAL_DESIGN.md with full spec
This commit is contained in:
commit
902133edd3
4655 changed files with 1342691 additions and 0 deletions
58
venv/lib/python3.11/site-packages/mypy/test/testoutput.py
Normal file
58
venv/lib/python3.11/site-packages/mypy/test/testoutput.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
"""Test cases for `--output=json`.
|
||||
|
||||
These cannot be run by the usual unit test runner because of the backslashes in
|
||||
the output, which get normalized to forward slashes by the test suite on Windows.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from mypy import api
|
||||
from mypy.defaults import PYTHON3_VERSION
|
||||
from mypy.test.config import test_temp_dir
|
||||
from mypy.test.data import DataDrivenTestCase, DataSuite
|
||||
|
||||
|
||||
class OutputJSONsuite(DataSuite):
|
||||
files = ["outputjson.test"]
|
||||
|
||||
def run_case(self, testcase: DataDrivenTestCase) -> None:
|
||||
test_output_json(testcase)
|
||||
|
||||
|
||||
def test_output_json(testcase: DataDrivenTestCase) -> None:
|
||||
"""Runs Mypy in a subprocess, and ensures that `--output=json` works as intended."""
|
||||
mypy_cmdline = ["--output=json"]
|
||||
mypy_cmdline.append(f"--python-version={'.'.join(map(str, PYTHON3_VERSION))}")
|
||||
|
||||
# Write the program to a file.
|
||||
program_path = os.path.join(test_temp_dir, "main")
|
||||
mypy_cmdline.append(program_path)
|
||||
with open(program_path, "w", encoding="utf8") as file:
|
||||
for s in testcase.input:
|
||||
file.write(f"{s}\n")
|
||||
|
||||
output = []
|
||||
# Type check the program.
|
||||
out, err, returncode = api.run(mypy_cmdline)
|
||||
# split lines, remove newlines, and remove directory of test case
|
||||
for line in (out + err).rstrip("\n").splitlines():
|
||||
if line.startswith(test_temp_dir + os.sep):
|
||||
output.append(line[len(test_temp_dir + os.sep) :].rstrip("\r\n"))
|
||||
else:
|
||||
output.append(line.rstrip("\r\n"))
|
||||
|
||||
if returncode > 1:
|
||||
output.append("!!! Mypy crashed !!!")
|
||||
|
||||
# Remove temp file.
|
||||
os.remove(program_path)
|
||||
|
||||
# JSON encodes every `\` character into `\\`, so we need to remove `\\` from windows paths
|
||||
# and `/` from POSIX paths
|
||||
json_os_separator = os.sep.replace("\\", "\\\\")
|
||||
normalized_output = [line.replace(test_temp_dir + json_os_separator, "") for line in output]
|
||||
|
||||
assert normalized_output == testcase.output
|
||||
Loading…
Add table
Add a link
Reference in a new issue