-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: check hypothesis that it works for JSON
- Loading branch information
1 parent
a5d95f5
commit 12d663a
Showing
7 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
notifications: | ||
email: false | ||
|
||
language: python | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
cache: | ||
- pip | ||
|
||
env: | ||
- REQUIREMENTS=lowest | ||
- REQUIREMENTS=release DEPLOY=true | ||
# - REQUIREMENTS=devel | ||
|
||
python: | ||
- "2.7" | ||
- "3.5" | ||
- "3.6" | ||
|
||
before_install: | ||
- "travis_retry pip install --upgrade pip setuptools py" | ||
- "travis_retry pip install twine wheel coveralls requirements-builder" | ||
- "requirements-builder -e all --level=min setup.py > .travis-lowest-requirements.txt" | ||
- "requirements-builder -e all --level=pypi setup.py > .travis-release-requirements.txt" | ||
# - "requirements-builder -e all --level=dev --req requirements-devel.txt setup.py > .travis-devel-requirements.txt" | ||
|
||
install: | ||
- "travis_retry pip install -r .travis-${REQUIREMENTS}-requirements.txt" | ||
- "travis_retry pip install -e .[all]" | ||
|
||
script: | ||
- check-manifest | ||
- python setup.py test | ||
- sphinx-build -qnNW docs docs/_build/html | ||
|
||
after_success: | ||
- coveralls | ||
|
||
deploy: | ||
- provider: pypi | ||
user: jirikuncar | ||
password: | ||
secure: TODO | ||
distributions: "sdist bdist_wheel" | ||
on: | ||
tags: true | ||
python: "3.6" | ||
repo: jirikuncar/git-json-tree | ||
condition: $DEPLOY = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
include *.py | ||
include LICENSE | ||
recursive-include docs *.css | ||
recursive-include docs *.html | ||
recursive-include docs *.png | ||
recursive-include docs *.py | ||
recursive-include docs *.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Test Git-JSON-Tree library.""" | ||
|
||
from string import printable | ||
|
||
import hypothesis.strategies as st | ||
import pytest | ||
from dulwich.repo import Repo | ||
from hypothesis import assume, given, settings | ||
|
||
from git_json_tree import decode, encode | ||
|
||
|
||
@pytest.fixture() | ||
def repo(tmpdir): | ||
"""Create a repo.""" | ||
yield Repo.init_bare(str(tmpdir)) | ||
|
||
|
||
def json_data(): | ||
"""Generate JSON data.""" | ||
return st.recursive( | ||
st.none() | | ||
st.booleans() | | ||
st.integers() | | ||
st.floats(allow_nan=False) | | ||
st.text(printable), | ||
lambda children: | ||
st.lists(children) | | ||
st.dictionaries( | ||
st.text( | ||
set(printable) - set('/') | ||
), | ||
children, | ||
), | ||
max_leaves=500, | ||
) | ||
|
||
|
||
@given(data=json_data()) | ||
@settings(max_examples=1000, deadline=500) | ||
def test_encode_decode(data, repo): | ||
"""Test (d)encoding.""" | ||
assume(isinstance(data, (dict, list))) | ||
assert decode(repo, encode(repo, data)) == data |