Skip to content

Commit

Permalink
use pytest-examples (pydantic#465)
Browse files Browse the repository at this point in the history
* use pytest-examples

* fix docstring tests on emscripten

* working on linting examples

* fixing more examples

* update docstring

* updating examples

* all examples formatted

* reformat examples

* uprev deps

* revert coverage

* revert other uprevs

* remove "HYPOTHESIS_PROFILE: slow"

* fix ci

* linting and add tmate

* move tmate

* add -g to RUSTFLAGS

* allow coverage to fail
  • Loading branch information
samuelcolvin authored Mar 24, 2023
1 parent dcf1fdd commit 70dcb06
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 180 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: coverage-v1
key: coverage-v2

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'
Expand All @@ -47,9 +47,6 @@ jobs:
- run: pip freeze

- run: coverage run -m pytest
env:
BENCHMARK_VS_PYDANTIC: 1
HYPOTHESIS_PROFILE: slow

- run: ls -lha
- run: coverage xml
Expand Down Expand Up @@ -262,6 +259,7 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
allowed-failures: coverage

build:
name: build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ rust-benchmark:
cargo rust-bench

.PHONY: testcov
testcov: build-coverage test
testcov: build-coverage
@rm -rf htmlcov
@mkdir -p htmlcov
coverage run -m pytest
coverage report
coverage html -d htmlcov/python
coverage-prepare html pydantic_core/*.so

Expand Down
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,35 @@ Example of usage:
```py
from pydantic_core import SchemaValidator, ValidationError

v = SchemaValidator({
'type': 'typed-dict',
'fields': {
'name': {
'type': 'typed-dict-field',
'schema': {
'type': 'str',

v = SchemaValidator(
{
'type': 'typed-dict',
'fields': {
'name': {
'type': 'typed-dict-field',
'schema': {
'type': 'str',
},
},
},
'age': {
'type': 'typed-dict-field',
'schema': {
'type': 'int',
'ge': 18,
'age': {
'type': 'typed-dict-field',
'schema': {
'type': 'int',
'ge': 18,
},
},
'is_developer': {
'type': 'typed-dict-field',
'schema': {
'type': 'default',
'schema': {'type': 'bool'},
'default': True,
},
},
},
'is_developer': {
'type': 'typed-dict-field',
'schema': {
'type': 'default',
'schema': {'type': 'bool'},
'default': True,
}
},
},
})
}
)

r1 = v.validate_python({'name': 'Samuel', 'age': 35})
assert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True}
Expand Down
Loading

0 comments on commit 70dcb06

Please sign in to comment.