Fix coverage setup

This commit is contained in:
NateScarlet 2019-03-12 22:54:23 +08:00
parent 0bb4b18e1d
commit daa7f3b43c
No known key found for this signature in database
GPG Key ID: 5C242793B070309C
6 changed files with 6 additions and 13 deletions

View File

@ -16,9 +16,10 @@ before_script:
- git checkout master - git checkout master
- ./cc-test-reporter before-build - ./cc-test-reporter before-build
script: script:
- pytest - coverage run -m pytest
- coverage run -a ./update.py --release - coverage run -a ./update.py --release
after_script: after_script:
- coverage xml && coverage report
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
branches: branches:
only: only:

View File

@ -1,2 +0,0 @@
[pytest]
addopts = --cov=.

View File

@ -2,4 +2,4 @@ requests ~= 2.21.0
beautifulsoup4 ~= 4.7.1 beautifulsoup4 ~= 4.7.1
tqdm ~= 4.30.0 tqdm ~= 4.30.0
pytest ~= 4.3.0 pytest ~= 4.3.0
pytest-cov ~= 2.6.1 coverage ~= 4.5.3

0
tests/__init__.py Normal file
View File

View File

@ -1,16 +1,9 @@
"""pytest config""" """Tools for files. """
import os import os
import sys
__dirname__ = os.path.abspath(os.path.dirname(__file__)) __dirname__ = os.path.abspath(os.path.dirname(__file__))
def _file_path(*other): def _file_path(*other):
return os.path.abspath(os.path.join(__dirname__, *other)) return os.path.abspath(os.path.join(__dirname__, *other))
def pytest_configure(config):
sys.path.insert(0, _file_path('..'))
return config

View File

@ -2,9 +2,10 @@
import json import json
import sys import sys
from conftest import _file_path
from fetch_holidays import CustomJSONEncoder, DescriptionParser from fetch_holidays import CustomJSONEncoder, DescriptionParser
from .filetools import _file_path
def _normalize(iterable): def _normalize(iterable):
return sorted(json.loads(json.dumps(list(iterable), cls=CustomJSONEncoder)), return sorted(json.loads(json.dumps(list(iterable), cls=CustomJSONEncoder)),