Skip to content

Commit 5e610bf

Browse files
committed
get tests to pass
1 parent 8f0ffae commit 5e610bf

File tree

6 files changed

+71
-68
lines changed

6 files changed

+71
-68
lines changed

pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
name = "project"
55
version = "0.0.0"
66
description = "Scripts for managing the ReactPy respository"
7-
dependencies = ["invoke", "ruff", "black"]
7+
dependencies = [
8+
"invoke",
9+
"ruff",
10+
"black",
11+
"toml",
12+
]
813

914
# --- Hatch ----------------------------------------------------------------------------
1015

src/py/reactpy/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
.coverage.*
2+
13
# --- Build Artifacts ---
24
reactpy/_static

src/py/reactpy/pyproject-temp.toml

-61
This file was deleted.

src/py/reactpy/pyproject.toml

+41-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ dependencies = [
3636
"lxml >=4",
3737
]
3838
[project.optional-dependencies]
39+
all = ["reactpy[starlette,sanic,fastapi,flask,tornado,testing]"]
40+
3941
starlette = [
4042
"starlette >=0.13.6",
4143
"uvicorn[standard] >=0.19.0",
@@ -73,13 +75,24 @@ Source = "https://github.com/reactive-python/reactpy"
7375
path = "reactpy/__init__.py"
7476

7577
[tool.hatch.envs.default]
78+
features = ["all"]
7679
pre-install-command = "hatch run build --hooks-only"
7780
dependencies = [
7881
"coverage[toml]>=6.5",
7982
"pytest",
83+
"pytest-asyncio>=0.17",
84+
"pytest-mock",
85+
"pytest-rerunfailures",
86+
"pytest-timeout",
87+
"responses",
88+
"playwright",
89+
# I'm not quite sure why this needs to be installed for tests with Sanic to pass
90+
"sanic-testing",
91+
# Used to generate model changes from layout update messages
92+
"jsonpointer",
8093
]
8194
[tool.hatch.envs.default.scripts]
82-
test = "pytest {args:tests}"
95+
test = "playwright install && pytest {args:tests}"
8396
test-cov = "coverage run -m pytest {args:tests}"
8497
cov-report = [
8598
"- coverage combine",
@@ -102,8 +115,8 @@ dependencies = [
102115
]
103116

104117
[tool.hatch.envs.lint.scripts]
105-
typing = "mypy --install-types --non-interactive {args:reactpy tests}"
106-
all = ["typing"]
118+
types = "mypy --strict reactpy"
119+
all = ["types"]
107120

108121
[[tool.hatch.build.hooks.build-scripts.scripts]]
109122
work_dir = "../../js"
@@ -116,6 +129,23 @@ artifacts = [
116129
"app/dist/"
117130
]
118131

132+
# --- Pytest ---------------------------------------------------------------------------
133+
134+
[tool.pytest.ini_options]
135+
testpaths = "tests"
136+
xfail_strict = true
137+
python_files = "*asserts.py test_*.py"
138+
asyncio_mode = "auto"
139+
140+
# --- MyPy -----------------------------------------------------------------------------
141+
142+
[tool.mypy]
143+
incremental = false
144+
ignore_missing_imports = true
145+
warn_unused_configs = true
146+
warn_redundant_casts = true
147+
warn_unused_ignores = true
148+
119149
# --- Coverage -------------------------------------------------------------------------
120150

121151
[tool.coverage.run]
@@ -131,8 +161,16 @@ reactpy = ["reactpy", "*/reactpy/reactpy"]
131161
tests = ["tests", "*/reactpy/tests"]
132162

133163
[tool.coverage.report]
164+
fail_under = 100
165+
show_missing = true
166+
skip_covered = true
167+
sort = "Name"
134168
exclude_lines = [
135169
"no cov",
170+
'\.\.\.\$',
136171
"if __name__ == .__main__.:",
137172
"if TYPE_CHECKING:",
138173
]
174+
omit = [
175+
"reactpy/__main__.py",
176+
]

src/py/reactpy/tests/test__option.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_deprecated_option():
105105
opt = DeprecatedOption("is deprecated!", "A_FAKE_OPTION", None)
106106

107107
with pytest.warns(DeprecationWarning, match="is deprecated!"):
108-
assert opt.current == "is deprecated"
108+
assert opt.current is None
109109

110110
with pytest.warns(DeprecationWarning, match="is deprecated!"):
111111
opt.current = "something"

tasks.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from __future__ import annotations
22

33
import json
4+
import logging
45
import os
56
import re
7+
from shlex import join
8+
import sys
9+
import toml
610
from dataclasses import dataclass
7-
from logging import getLogger
811
from pathlib import Path
912
from shutil import rmtree
1013
from typing import TYPE_CHECKING, Any, Callable
@@ -33,7 +36,16 @@ def __call__(
3336
# --- Constants ------------------------------------------------------------------------
3437

3538

36-
log = getLogger(__name__)
39+
log = logging.getLogger(__name__)
40+
log.setLevel("INFO")
41+
log_handler = logging.StreamHandler(sys.stdout)
42+
log_handler.setFormatter(logging.Formatter("%(message)s"))
43+
log.addHandler(log_handler)
44+
45+
46+
# --- Constants ------------------------------------------------------------------------
47+
48+
3749
ROOT = Path(__file__).parent
3850
SRC_DIR = ROOT / "src"
3951
JS_DIR = SRC_DIR / "js"
@@ -59,6 +71,11 @@ def env(context: Context):
5971
"""Install development environment"""
6072
in_py(context, "pip install -e .", hide="out")
6173
in_js(context, "npm ci", hide="out")
74+
for py_proj in PY_PROJECTS:
75+
py_proj_toml = toml.load(py_proj / "pyproject.toml")
76+
hatch_default_env = py_proj_toml["tool"]["hatch"]["envs"].get("default", {})
77+
hatch_default_deps = hatch_default_env.get("dependencies", [])
78+
context.run(f"pip install {' '.join(map(repr, hatch_default_deps))}")
6279

6380

6481
@task
@@ -70,6 +87,7 @@ def lint_py(context: Context, fix: bool = False):
7087
else:
7188
context.run("ruff .")
7289
context.run("black --check --diff .")
90+
in_py(context, "hatch run lint:all")
7391

7492

7593
@task
@@ -142,6 +160,7 @@ def publish(context: Context, dry_run: str = ""):
142160
def in_py(context: Context, *commands: str, **kwargs: Any) -> None:
143161
for p in PY_PROJECTS:
144162
with context.cd(p):
163+
log.info(f"Running commands in {p}...")
145164
for c in commands:
146165
context.run(c, **kwargs)
147166

0 commit comments

Comments
 (0)