Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Rework Model and Field tests #44

Merged
merged 3 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ matrix:
- python: 3.7
dist: xenial
sudo: true
- python: pypy
- python: pypy3

# command to install dependencies
install:
- make install-travis
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then make install-dev; else make install-plain; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then pip install codecov; fi

# command to run tests
script:
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then make lint; fi
- if [[ $TRAVIS_PYTHON_VERSION != 2.7 ]]; then make test; else make test-plain; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then make test; else make test-plain; fi

# command to upload coverage
after_success:
Expand Down
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.PHONY: help clean venv install install-travis install-all lint sort-imports \
.PHONY: help clean venv install install-plain install-dev install-all lint sort-imports \
test test-plain docs docs-clean docs-open docs-test dist release

PYTHON := python3
VIRTUAL_ENV := $(or $(VIRTUAL_ENV), $(VIRTUAL_ENV), venv)

help: ## Show this message and exit.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-14s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-13s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

clean: docs-clean ## Remove all build artifacts.
rm -rf build dist wheels venv *.egg-info
Expand All @@ -15,15 +15,17 @@ clean: docs-clean ## Remove all build artifacts.
venv: ## Create virtualenv.
virtualenv --python=$(PYTHON) venv

install: ## Install package.
$(VIRTUAL_ENV)/bin/pip install -e .
install: ## Install package and all features.
$(VIRTUAL_ENV)/bin/pip install -e ".[toml,yaml]"

install-travis: ## Install package and linting and testing dependencies.
$(VIRTUAL_ENV)/bin/pip install -e ".[toml,yaml,linting,testing]"
$(VIRTUAL_ENV)/bin/pip install codecov
install-plain: ## Install package, all features, and testing dependencies.
$(VIRTUAL_ENV)/bin/pip install -e ".[toml,yaml,dev.test]"

install-all: ## Install package and development dependencies.
$(VIRTUAL_ENV)/bin/pip install -e ".[toml,yaml,linting,testing,documenting,packaging]"
install-dev: ## Install package, all features, and linting and testing dependencies.
$(VIRTUAL_ENV)/bin/pip install -e ".[toml,yaml,dev.lint,dev.test]"

install-all: install-dev ## Install package, all features, and all development dependencies.
$(VIRTUAL_ENV)/bin/pip install sphinx twine

lint: ## Run all lints.
$(VIRTUAL_ENV)/bin/flake8 --max-complexity 10 .
Expand Down
18 changes: 4 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
with io.open(os.path.join(here, 'README.rst'), encoding='utf8') as f:
metadata['long_description'] = f.read()

# Primary requirements
install_requires = [
'isodate>=0.6.0<0.7.0',
'six>=1.0.0<2.0.0',
'validators>=0.12.0<0.13.0'
]

toml_requires = [
'toml>=0.10.0<0.11.0'
]

yaml_requires = [
'ruamel.yaml>=0.15.0<0.16.0'
]

# Development requirements
lint_requires = [
'flake8',
'flake8-docstrings',
Expand All @@ -50,24 +50,14 @@
'pytest-doctest-import'
]

document_requires = [
'sphinx'
]

package_requires = [
'twine'
]

setup(
# Options
install_requires=install_requires,
extras_require={
'toml': toml_requires,
'yaml': yaml_requires,
'linting': lint_requires,
'testing': test_requires,
'documenting': document_requires,
'packaging': package_requires
'dev.lint': lint_requires,
'dev.test': test_requires
},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
packages=find_packages('src'),
Expand Down
12 changes: 1 addition & 11 deletions src/serde/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,7 @@ def __hash__(self):
"""
Return a hash value for this Model.
"""
values = []

for name in self._fields.keys():
value = getattr(self, name)

if isinstance(value, list):
values.append((name, frozenset(value)))
else:
values.append((name, value))

return hash(tuple(values))
return hash(tuple((name, getattr(self, name)) for name in self._fields.keys()))

def __repr__(self):
"""
Expand Down