Skip to content

Commit 12cfe29

Browse files
committed
Run examples and benchmark on CI
1 parent 94086ba commit 12cfe29

File tree

7 files changed

+52
-15
lines changed

7 files changed

+52
-15
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Makefile linguist-vendored

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ python:
44
- 3.6
55
- 3.7
66
env:
7-
- PIP_CACHE_DIR: $HOME/.cache/pip
8-
- PIPENV_CACHE_DIR: $HOME/.cache/pipenv
7+
- PIP_CACHE_DIR: $HOME/.cache/pip PIPENV_CACHE_DIR: $HOME/.cache/pipenv
98
cache:
109
directories:
1110
$HOME/.cache/pip
@@ -14,7 +13,7 @@ install:
1413
- pip install pipenv
1514
- make setup
1615
script:
17-
- make test
16+
- make test examples bench
1817
after_success:
1918
- make coverage
2019
- coveralls

Makefile

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
.PHONY: all setup build test coverage pep8 mypy fmt docs open-docs bench
1+
SHELL:=/bin/bash
22

3-
all: setup test pep8 mypy docs
3+
.PHONY: all setup build test examples coverage pep8 mypy fmt docs open-docs bench
4+
5+
all: setup pep8 mypy docs test examples
46

57
setup:
68
pipenv install --dev
79
pipenv run pip list
10+
pushd examples && pipenv install --dev && popd
11+
pushd bench && pipenv install --dev && popd
812

913
build:
1014
pipenv run python setup.py sdist
1115
pipenv run python setup.py bdist_wheel
1216

1317
test:
14-
pytest tests --doctest-modules serde -v
18+
pipenv run pytest tests --doctest-modules serde -v
19+
20+
examples:
21+
pushd examples && pipenv run python runner.py && popd
1522

1623
coverage:
17-
pytest tests --doctest-modules serde -v --cov=serde --cov-report term --cov-report xml
24+
pipenv run pytest tests --doctest-modules serde -v --cov=serde --cov-report term --cov-report xml
1825

1926
pep8:
2027
pipenv run flake8

bench/bench.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def se_raw(cls: Type, **kwargs):
329329

330330

331331
def de_pyserde(cls: Type, data: str):
332-
return serde.json.from_json(cls, data, strict=False)
332+
return serde.json.from_json(cls, data)
333333

334334

335335
def se_pyserde(cls: Type, **kwargs):
@@ -407,9 +407,9 @@ def main():
407407
if f:
408408
f()
409409
else:
410-
de_small()
411-
de_medium()
412-
de_pri_container()
410+
# de_small()
411+
# de_medium()
412+
# de_pri_container()
413413
se_small()
414414
se_astuple()
415415
se_asdict()
@@ -464,7 +464,7 @@ def se_small():
464464
def se_astuple():
465465
print('--- astuple small ---')
466466
exp = (10, 'hoge', 100.0, True)
467-
profile('datclass', astuple_raw, RawSmall(10, 'hoge', 100.0, True), expected=exp)
467+
profile('raw', astuple_raw, RawSmall(10, 'hoge', 100.0, True), expected=exp)
468468
profile('pyserde', astuple_pyserde, SerdeSmall(10, 'hoge', 100.0, True), expected=exp)
469469

470470
print('--- astuple medium ---')
@@ -534,14 +534,14 @@ def se_astuple():
534534
100.0,
535535
True,
536536
)
537-
profile('datclass', astuple_raw, raw, expected=exp)
537+
profile('raw', astuple_raw, raw, expected=exp)
538538
profile('pyserde', astuple_pyserde, sm, expected=exp)
539539

540540

541541
def se_asdict():
542542
print('--- asdict small ---')
543543
exp = {'i': 10, 's': 'hoge', 'f': 100.0, 'b': True}
544-
profile('datclass', asdict_raw, RawSmall(10, 'hoge', 100.0, True), expected=exp)
544+
profile('raw', asdict_raw, RawSmall(10, 'hoge', 100.0, True), expected=exp)
545545
profile('pyserde', asdict_pyserde, SerdeSmall(10, 'hoge', 100.0, True), expected=exp)
546546

547547

examples/__init__.py

Whitespace-only changes.

examples/runner.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import sys
2+
3+
import env
4+
import jsonfile
5+
import rename
6+
import skip
7+
import tomlfile
8+
import yamlfile
9+
10+
11+
def run_all():
12+
run(env)
13+
run(jsonfile)
14+
run(rename)
15+
run(skip)
16+
run(tomlfile)
17+
run(yamlfile)
18+
19+
20+
def run(module):
21+
print(f'running {module.__name__}')
22+
module.main()
23+
24+
25+
if __name__ == '__main__':
26+
try:
27+
run_all()
28+
except:
29+
sys.exit(1)

examples/yamlfile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class Info:
2525
@dataclass
2626
class Parameter:
2727
name: str
28-
infield: str = field(metadata={'serde_rename': 'in'})
28+
# not yet supported.
29+
# infield: str = field(metadata={'serde_rename': 'in'})
2930
type: str
3031
required: bool
3132

0 commit comments

Comments
 (0)