Skip to content

Commit 82afcef

Browse files
committed
switch to tox for more granular test parametrization
1 parent e2bb6c3 commit 82afcef

15 files changed

+80
-33
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ venv
1616
MANIFEST
1717
build
1818
dist
19+
.eggs
1920
*.egg-info
2021
__pycache__/
2122
*.py[cod]
23+
.tox
2224

2325
# --- PyEnv ---
2426
.python-version

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ python:
66
- 3.6
77
- 3.7
88
- 3.8
9-
- 3.8-dev
109

1110
cache: apt
1211

@@ -27,12 +26,10 @@ before_install:
2726
- sudo chmod +x /usr/bin/chromedriver
2827

2928
install:
30-
- pip install -r requirements.txt
31-
- python setup.py build
32-
- pip install .[all]
29+
- pip install -r requirements/ci.txt
3330

3431
script:
35-
- bash scripts/test.sh
32+
- tox
3633

3734
after_success:
3835
- codecov

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ graft idom/client/static/
22
prune idom/client/static/node_modules
33
include idom/py.typed
44
include LICENSE
5+
include requirements/prod.txt
6+
include requirements/extras.txt
7+
include README.md
8+
include scripts/build.sh

docs/source/core-concepts.rst

+14-15
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ ever be removed from the model. Then you'll just need to call and await a
134134

135135
return idom.html.button({"onClick": increment}, [f"Click count: {count}"])
136136

137-
138137
click_count = ClickCount(0)
139-
layout = idom.Layout(click_count)
140-
update = await layout.render()
141-
138+
async with idom.Layout(click_count) as layout:
139+
update = await layout.render()
142140

143141
assert update.src == click_count.id
144142
assert update.new == {
@@ -174,13 +172,17 @@ method. Then we just have to re-render the layout and see what changed:
174172

175173
from idom.core.layout import LayoutEvent
176174

177-
event_handler_id = update.new[click_count.id]["eventHandlers"]["onClick"]["target"]
178-
dummy_event = LayoutEvent(event_handler_id, [{}])
175+
click_count = ClickCount(0)
176+
async with idom.Layout(click_count) as layout:
177+
first_udpate = await layout.render() # same as above
178+
179+
event_handler_id = first_udpate.new[click_count.id]["eventHandlers"]["onClick"]["target"]
180+
dummy_event = LayoutEvent(event_handler_id, [{}])
179181

180-
await layout.trigger(dummy_event)
182+
await layout.trigger(dummy_event)
183+
second_update = await layout.render()
181184

182-
new_update = await layout.render()
183-
assert new_update.new[click_count.id]["children"][0]["data"] == "Click count: 1"
185+
assert second_update.new[click_count.id]["children"][0]["data"] == "Click count: 1"
184186

185187

186188
Layout Renderer
@@ -201,7 +203,6 @@ callback that's called by the renderer to events it should execute.
201203
from idom.core import SingleStateRenderer, EventHandler
202204
from idom.core.layout import LayoutEvent
203205

204-
layout = idom.Layout(ClickCount(0))
205206
sent_updates = []
206207

207208

@@ -224,11 +225,9 @@ callback that's called by the renderer to events it should execute.
224225
return event
225226

226227

227-
renderer = SingleStateRenderer(layout)
228-
229-
context = None # see note below
230-
231-
await renderer.run(send, recv, context)
228+
async with SingleStateRenderer(idom.Layout(ClickCount(0))) as renderer:
229+
context = None # see note below
230+
await renderer.run(send, recv, context)
232231

233232
assert len(sent_updates) == 5
234233

idom/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__version__ = _get_distribution(__name__).version
2323
except _DistributionNotFound: # pragma: no cover
2424
# package is not installed
25-
pass
25+
__version__ = "0.0.0"
2626

2727
# try to automatically setup the dialect's import hook
2828
try:

idom/core/utils.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
)
1717

1818
if sys.version_info >= (3, 7): # pragma: no cover
19-
from contextlib import (
20-
asynccontextmanager,
21-
AsyncExitStack,
22-
) # noqa
19+
from contextlib import asynccontextmanager, AsyncExitStack # noqa
2320
else: # pragma: no cover
2421
from async_generator import asynccontextmanager
2522
from async_exit_stack import AsyncExitStack

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
-r requirements/prod.txt
22
-r requirements/dev.txt
33
-r requirements/docs.txt
4-
-r requirements/test.txt
54
-r requirements/extras.txt

requirements/ci.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r tox.txt
2+
tox-travis
3+
codecov

requirements/dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ notebook
44
twine
55
wheel
66
setuptools_scm
7+
-r tox.txt

requirements/lint.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
black
2+
flake8
3+
pep8-naming

requirements/mypy.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mypy

requirements/test.txt

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
pytest>=5.4.0
1+
pytest
22
pytest-asyncio
33
pytest-cov
44
pytest-mock
5-
mypy>=0.750
6-
black
7-
flake8
8-
pep8-naming
9-
selenium
105
flask
11-
codecov
6+
selenium
7+
ipython

requirements/tox.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tox
2+
tox-wheel

setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ select = B,C,E,F,W,T4,B9,N
1212
exclude =
1313
idom/client/static/node_modules/*
1414
docs/source/widgets/*
15+
.eggs/*
16+
.tox/*
1517

1618
[tool:pytest]
1719
testpaths = tests

tox.ini

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
[tox]
3+
envlist = {py36,py37}-test, py38-{test,mypy,lint,docs,cov}
4+
5+
[travis]
6+
python =
7+
3.6: py36-test
8+
3.7: py37-test
9+
3.8: py38-{test,mypy,lint,docs,cov}
10+
11+
[testenv]
12+
wheel = true
13+
extras = all
14+
usedevelop =
15+
test: false
16+
cov: true
17+
deps =
18+
test: -r requirements/test.txt
19+
cov: -r requirements/test.txt
20+
commands =
21+
test: pytest tests --no-cov --headless
22+
cov: pytest tests --headless
23+
24+
[testenv:py38-mypy]
25+
skip_install = false
26+
extras = all
27+
deps = mypy
28+
commands = mypy --strict idom
29+
30+
[testenv:py38-lint]
31+
skip_install = true
32+
deps = -r requirements/lint.txt
33+
commands =
34+
black . --check --exclude "idom/client/static/node_modules/.*"
35+
flake8 idom tests docs
36+
37+
[testenv:py38-docs]
38+
deps = -r requirements/docs.txt
39+
commands =
40+
sphinx-build -b html docs/source docs/build
41+
sphinx-build -b doctest docs/source docs/build

0 commit comments

Comments
 (0)