Setup test coverage
This commit is contained in:
parent
4e215913c3
commit
79d0177c41
2
.coveragerc
Normal file
2
.coveragerc
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[run]
|
||||||
|
omit = tests/*
|
||||||
|
|
@ -6,15 +6,20 @@ before_install:
|
||||||
install:
|
install:
|
||||||
- go get github.com/github/hub && hub --version
|
- go get github.com/github/hub && hub --version
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
||||||
|
- chmod +x ./cc-test-reporter
|
||||||
cache:
|
cache:
|
||||||
- pip
|
- pip
|
||||||
before_script:
|
before_script:
|
||||||
- git config credential.helper "store --file=.git/credentials"
|
- git config credential.helper "store --file=.git/credentials"
|
||||||
- echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
|
- echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
|
||||||
- git checkout master
|
- git checkout master
|
||||||
|
- ./cc-test-reporter before-build
|
||||||
script:
|
script:
|
||||||
- pytest
|
- pytest
|
||||||
- ./update.py --release
|
- coverage run -a ./update.py --release
|
||||||
|
after_script:
|
||||||
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# holiday-cn
|
# holiday-cn
|
||||||
|
|
||||||
[](https://travis-ci.org/NateScarlet/holiday-cn) [](https://github.com/NateScarlet/holiday-cn/releases/latest) [](http://calver.org) [](https://codeclimate.com/github/NateScarlet/holiday-cn/maintainability) 
|
[](https://travis-ci.org/NateScarlet/holiday-cn) [](https://github.com/NateScarlet/holiday-cn/releases/latest) [](http://calver.org) [](https://codeclimate.com/github/NateScarlet/holiday-cn/maintainability) [](https://codeclimate.com/github/NateScarlet/holiday-cn/test_coverage) 
|
||||||
|
|
||||||
中国法定节假日数据 自动每日抓取国务院公告
|
中国法定节假日数据 自动每日抓取国务院公告
|
||||||
|
|
||||||
|
|
|
||||||
2
pytest.ini
Normal file
2
pytest.ini
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[pytest]
|
||||||
|
addopts = --cov=.
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
requests ~= 2.21.0
|
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-cov ~= 2.6.1
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
"""Test module `fetch_holidays`. """
|
"""Test module `fetch_holidays`. """
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from fetch_holidays import CustomJSONEncoder, DescriptionParser
|
from fetch_holidays import CustomJSONEncoder, DescriptionParser
|
||||||
|
|
||||||
|
__dirname__ = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
def _file_path(*other):
|
||||||
|
|
||||||
|
return os.path.join(__dirname__, *other)
|
||||||
|
|
||||||
|
|
||||||
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)),
|
||||||
|
|
@ -11,7 +19,7 @@ def _normalize(iterable):
|
||||||
|
|
||||||
|
|
||||||
def _generate_tests():
|
def _generate_tests():
|
||||||
with open('description_parsing_cases.json', 'r', encoding='utf-8', ) as f:
|
with open(_file_path('description_parsing_cases.json'), 'r', encoding='utf-8', ) as f:
|
||||||
cases = json.load(f)
|
cases = json.load(f)
|
||||||
|
|
||||||
def create_test(case):
|
def create_test(case):
|
||||||
Loading…
Reference in New Issue
Block a user