HtmlTestRunner icon indicating copy to clipboard operation
HtmlTestRunner copied to clipboard

no response after click "view"

Open FrancisJen opened this issue 6 years ago • 2 comments

no response after click "view"

FrancisJen avatar May 04 '18 15:05 FrancisJen

source code #coding:utf-8

import unittest import json import HtmlTestRunner import unittest.mock from demo import RunMain from mock_demo import mock_test class TestMethod(unittest.TestCase): def setUp(self): self.run=RunMain() def test_03(self): url = 'http://coding.imooc.com/api/cate' data = { 'timestamp':'1507034803124', 'uid':'5249191', 'uuid':'5ae7d1a22c82fb89c78f603420870ad7', 'secrect':'078474b41dd37ddd5efeb04aa591ec12', 'token':'7d6f14f21ec96d755de41e6c076758dd', 'cid':'0', 'errorCode':1001 } #self.run.run_main = mock.Mock(return_value=data) res = mock_test(self.run.run_main,data,url,"POST",data) #res = self.run.run_main(url,'POST',data)

	print(res)
	self.assertEqual(res['errorCode'],1001,"测试失败")
	print("这是第一个case")

#@unittest.skip('test_02')	
def test_02(self):
	
	url = 'http://coding.imooc.com/api/cate'
	data = {
		'timestamp':'1507034803124',
		'uid':'5249191',
		'uuid':'5ae7d1a22c82fb89c78f603420870ad7',
		'secrect':'078474b41dd37ddd5efeb04aa591ec12',
		'token':'7d6f14f21ec96d755de41e6c076758dd',
		'cid':'0'
	}

	res = self.run.run_main(url,'POST',data)
	self.assertEqual(res['errorCode'],1001,"测试失败")
	print("这是第二个case")
	#mock

if name == 'main': # unittest.main() # filepath = "../report/htmlreport.html" # fp = file(filepath, 'wb') suite = unittest.TestSuite() suite.addTest(TestMethod('test_02')) suite.addTest(TestMethod('test_03')) runner = HtmlTestRunner.HTMLTestRunner(output='example_dir') # runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='this is first report') runner.run(suite)

FrancisJen avatar May 04 '18 15:05 FrancisJen

Not sure are you solve this problem.Check the Html report page source. it is used below jqure.min.js <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

please make you can access this normally.

if can not ,please change the url to

or or dowmload the jqure.min.js and chage it to absolute path

the sample html path is below, change the "report_template.html" that if you install via pip \Python\Python37-32\Lib\site-packages\HtmlTestRunner\template

Lsanme avatar Aug 17 '18 01:08 Lsanme