* my.core.serialize: simplejson support, more types I added a couple extra checks to the default function, serializing datetime, dates and dataclasses (incase orjson isn't installed) (copied from below) if orjson couldn't be imported, try simplejson This is included for compatibility reasons because orjson is rust-based and compiling on rarer architectures may not work out of the box as an example, I've been having issues getting it to install on my phone (termux/android) unlike the builtin JSON modue which serializes NamedTuples as lists (even if you provide a default function), simplejson correctly serializes namedtuples to dictionaries this just gives another option to people, simplejson is pure python so no one should have issues with that. orjson is still way faster, so still preferable if its easy and theres a precompiled build for your architecture (which there typically is) If you're ever running this with simplejson installed and not orjson, its pretty easy to tell as the JSON styling is different; orjson has no spaces between tokens, simplejson puts spaces between tokens. e.g. simplejson: {"a": 5, "b": 10} orjson: {"a":5,"b":10}
137 lines
4.9 KiB
INI
137 lines
4.9 KiB
INI
[tox]
|
|
minversion = 3.5
|
|
|
|
[testenv]
|
|
passenv = CI CI_*
|
|
|
|
|
|
# just the very core tests with minimal dependencies
|
|
[testenv:tests-core]
|
|
commands =
|
|
pip install -e .[testing]
|
|
python3 -m pytest \
|
|
tests/core.py \
|
|
tests/sqlite.py \
|
|
tests/get_files.py \
|
|
{posargs}
|
|
|
|
|
|
# todo maybe also have core tests and misc tests? since ideally want them without dependencies
|
|
[testenv:tests-all]
|
|
# deliberately set to nonexistent path to check the fallback logic
|
|
# TODO not sure if need it?
|
|
setenv = MY_CONFIG = nonexistent
|
|
commands =
|
|
pip install -e .[testing]
|
|
|
|
# installed to test my.core.serialize while using simplejson and not orjson
|
|
pip install simplejson
|
|
python3 -m pytest \
|
|
tests/serialize_simplejson.py \
|
|
{posargs}
|
|
|
|
pip install cachew
|
|
pip install orjson
|
|
|
|
hpi module install my.location.google
|
|
pip install ijson # optional dependency
|
|
|
|
hpi module install my.time.tz.via_location
|
|
|
|
hpi module install my.calendar.holidays
|
|
|
|
# my.body.weight dep
|
|
hpi module install my.orgmode
|
|
|
|
hpi module install my.coding.commits
|
|
|
|
hpi module install my.pdfs
|
|
|
|
python3 -m pytest tests \
|
|
# ignore some tests which might take a while to run on ci..
|
|
--ignore tests/takeout.py \
|
|
--ignore tests/extra/polar.py \
|
|
# dont run simplejson compatability test since orjson is now installed
|
|
--ignore tests/serialize_simplejson.py
|
|
{posargs}
|
|
|
|
|
|
[testenv:demo]
|
|
commands =
|
|
pip install git+https://github.com/karlicoss/hypexport
|
|
./demo.py
|
|
|
|
|
|
[testenv:mypy-core]
|
|
whitelist_externals = cat
|
|
commands =
|
|
pip install -e .[testing,optional]
|
|
pip install orgparse # used it core.orgmode?
|
|
# todo add tests?
|
|
python3 -m mypy --install-types --non-interactive \
|
|
-p my.core \
|
|
--txt-report .coverage.mypy-core \
|
|
--html-report .coverage.mypy-core \
|
|
{posargs}
|
|
cat .coverage.mypy-core/index.txt
|
|
|
|
|
|
# specific modules that are known to be mypy compliant (to avoid false negatives)
|
|
# todo maybe split into separate jobs? need to add comment how to run
|
|
[testenv:mypy-misc]
|
|
commands =
|
|
pip install -e .[testing,optional]
|
|
|
|
hpi module install my.orgmode
|
|
hpi module install my.endomondo
|
|
hpi module install my.github.ghexport
|
|
hpi module install my.hypothesis
|
|
hpi module install my.instapaper
|
|
hpi module install my.pocket
|
|
hpi module install my.reddit
|
|
hpi module install my.stackexchange.stexport
|
|
hpi module install my.pinboard
|
|
hpi module install my.arbtt
|
|
hpi module install my.coding.commits
|
|
hpi module install my.goodreads
|
|
hpi module install my.pdfs
|
|
hpi module install my.smscalls
|
|
|
|
# todo fuck. -p my.github isn't checking the subpackages?? wtf...
|
|
# guess it wants .pyi file??
|
|
python3 -m mypy --install-types --non-interactive \
|
|
-p my.endomondo \
|
|
-p my.github.ghexport \
|
|
-p my.hypothesis \
|
|
-p my.instapaper \
|
|
-p my.pocket \
|
|
-p my.smscalls \
|
|
-p my.reddit \
|
|
-p my.stackexchange.stexport \
|
|
-p my.pinboard \
|
|
-p my.body.exercise.cardio \
|
|
-p my.body.exercise.cross_trainer \
|
|
-p my.bluemaestro \
|
|
-p my.location.google \
|
|
-p my.time.tz.via_location \
|
|
-p my.calendar.holidays \
|
|
-p my.arbtt \
|
|
-p my.coding.commits \
|
|
-p my.goodreads \
|
|
-p my.pdfs \
|
|
--txt-report .coverage.mypy-misc \
|
|
--html-report .coverage.mypy-misc \
|
|
{posargs}
|
|
# txt report is a bit more convenient to view on CI
|
|
|
|
# note: this comment doesn't seem relevant anymore, but keeping it in case the issue happens again
|
|
# > ugh ... need to reset HOME, otherwise user's site-packages are somehow leaking into mypy's path...
|
|
# > see https://github.com/python/mypy/blob/f6fb60ef69738cbfe2dfe56c747eca8f03735d8e/mypy/modulefinder.py#L487
|
|
# > this is particularly annoying when user's config is leaking and mypy isn't running against the repository config
|
|
|
|
|
|
# useful flags:
|
|
# * sitepackages = true to inherit user/globally installed packages (default false)
|
|
# * skip_install = true -- not sure when useful? (default false)
|
|
# * -e to run specific subenvironment
|
|
# * pass arguments with -- , e.g. `tox -e tests -- -k some_test_name` to only run one test with pytest
|