1
テストカバレッジにはカバレッジレポートのフラスコ依存性も含まれているのはなぜですか。テストカバレッジにもカバレッジレポートのフラスコ依存性が含まれる理由
src/__init__.py 11 0 100%
src/appforms.py 17 0 100%
src/config.py 20 0 100%
src/controller.py 67 38 43% 35-42, 47-61, 66-75, 80, 85, 90, 95, 100, 105, 110, 115, 120
src/dataStruct.py 1 0 100%
src/model.py 111 57 49% 30-80, 88, 104, 111-118, 133-137, 159-169, 178-179, 184-187
src/timeUtils.py 41 33 20% 27-34, 52-66, 72-79, 87-90
src/utils.py 80 53 34% 21, 29, 34-43, 49-60, 71-75, 79-82, 90, 93, 98, 101, 109-114, 117-126
src/views.py 126 60 52% 41, 44-63, 75, 105-156, 172, 177, 193-194, 205-220, 227
src/visitorTracking.py 20 4 80% 37-45
tests/test_basic.py 36 0 100%
-------------------------------------------------------------------------------------------------
は、私が唯一のいくつかの基本的なテストを書いた:私はこれだけを見ると期待large_report_file_saved_to_pastebin
:その後、coverage report -m
は、このを見てくださいcoverage run tests/test_basic.py
:
iは、次のコマンドを実行します。カバレッジを調整したい:
import os
import sys
import unittest
import stubout
import mox
sys.path.insert(0, os.getcwd())
from src import app
from src import utils as _utils
from src.model import db
from src import timeUtils as _timeUtils
mockData = {u'city':
{
u'country': u'IN',
u'population': 0,
u'id': 1259775,
u'coord': {u'lat': 31.0292,
u'lon': 75.7842},
u'name': u'Phillaur'},
u'message': 4.410899,
u'list': [{u'clouds': 0,
u'temp': {u'min': 23.68,
u'max': 34.04,
u'eve': 32.79,
u'morn': 34.04,
u'night': 23.68,
u'day': 34.04},
u'humidity': 53,
u'pressure': 988.76,
u'weather': [{u'main': u'Clear',
u'id': 800,
u'icon': u'01d',
u'description': u'sky is clear'}],
u'dt': 1505887200,
u'speed': 0.84,
u'deg': 233}],
u'cod': u'200',
u'cnt': 1
}
class BasicTests(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['DEBUG'] = False
self.app = app.test_client()
def test_index_page(self):
self.mox = mox.Mox()
self.mox.StubOutWithMock(_utils, "getClientIp")
_utils.getClientIp().AndReturn(["127.0.0.1"])
response = self.app.get('/', follow_redirects=True)
self.addCleanup(self.mox.UnsetStubs)
self.assertEquals(response.status_code, 200)
def test_index_page_with_city(self):
self.mox = mox.Mox()
self.mox.StubOutWithMock(_utils, "getClientIp")
_utils.getClientIp().AndReturn(["127.0.0.1"])
self.mox.StubOutWithMock(_utils, "getWeatherURL")
_utils.getWeatherURL(u"Phillaur", count=u'1').AndReturn('/some/fake/URL')
self.mox.ReplayAll()
response = self.app.get('/?searchCity=Phillaur&count=1', follow_redirects=True)
self.assertEquals(response.status_code, 200)
self.mox.VerifyAll()
if __name__ == "__main__":
unittest.main()
ご協力いただければ幸いです。このようなプロジェクトのディレクトリ構造のため
ます。https: //stackoverflow.com/questions/34728734/python-unit-test-coverage – Anup
ありがとうございますAnup(y)。リンクは非常に近い答えを返します –