接口测试设计思想:

框架结构如下:

目录如下:

readme:

  1. config下的run_case_config.ini 文件说明:
  2. run_mode 0:获取所有sheet 1: if case_list=="":运行指定sheet页的所有用例 else 运行指定测试用例
  3.  
  4. python -m grpc_tools.protoc -I ./protoFile --python_out=./protoFile --grpc_python_out=./protoFile ./protoFile/ads_strategy.proto
  5. python -m grpc_tools.protoc -I. --python_out=./protoFile ./protoFile/ads_voice.proto
  6. protoc -I=$SRC_DIR descriptor_set_out=$DST_DIR/***.desc $SRC_DIR/***.proto

程序:

HTMLTestRunner.py文件:

  1. """
  2. A TestRunner for use with the Python unit testing framework. It
  3. generates a HTML report to show the result at a glance.
  4.  
  5. The simplest way to use this is to invoke its main method. E.g.
  6.  
  7. import unittest
  8. import HTMLTestRunner
  9.  
  10. ... define your tests ...
  11.  
  12. if __name__ == '__main__':
  13. HTMLTestRunner.main()
  14.  
  15. For more customization options, instantiates a HTMLTestRunner object.
  16. HTMLTestRunner is a counterpart to unittest's TextTestRunner. E.g.
  17.  
  18. # output to a file
  19. fp = file('my_report.html', 'wb')
  20. runner = HTMLTestRunner.HTMLTestRunner(
  21. stream=fp,
  22. title='My unit test',
  23. description='This demonstrates the report output by HTMLTestRunner.'
  24. )
  25.  
  26. # Use an external stylesheet.
  27. # See the Template_mixin class for more customizable options
  28. runner.STYLESHEET_TMPL = '<link rel="stylesheet" href="my_stylesheet.css" type="text/css">'
  29.  
  30. # run the test
  31. runner.run(my_test_suite)
  32.  
  33. ------------------------------------------------------------------------
  34. Copyright (c) 2004-2007, Wai Yip Tung
  35. All rights reserved.
  36.  
  37. Redistribution and use in source and binary forms, with or without
  38. modification, are permitted provided that the following conditions are
  39. met:
  40.  
  41. * Redistributions of source code must retain the above copyright notice,
  42. this list of conditions and the following disclaimer.
  43. * Redistributions in binary form must reproduce the above copyright
  44. notice, this list of conditions and the following disclaimer in the
  45. documentation and/or other materials provided with the distribution.
  46. * Neither the name Wai Yip Tung nor the names of its contributors may be
  47. used to endorse or promote products derived from this software without
  48. specific prior written permission.
  49.  
  50. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  51. IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  52. TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  53. PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  54. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  55. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  56. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  57. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  58. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  59. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  60. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. """
  62.  
  63. # URL: http://tungwaiyip.info/software/HTMLTestRunner.html
  64.  
  65. __author__ = "Wai Yip Tung"
  66. __version__ = "0.8.2"
  67.  
  68. """
  69. Change History
  70.  
  71. Version 0.8.2
  72. * Show output inline instead of popup window (Viorel Lupu).
  73.  
  74. Version in 0.8.1
  75. * Validated XHTML (Wolfgang Borgert).
  76. * Added description of test classes and test cases.
  77.  
  78. Version in 0.8.0
  79. * Define Template_mixin class for customization.
  80. * Workaround a IE 6 bug that it does not treat <script> block as CDATA.
  81.  
  82. Version in 0.7.1
  83. * Back port to Python 2.3 (Frank Horowitz).
  84. * Fix missing scroll bars in detail log (Podi).
  85. """
  86.  
  87. # TODO: color stderr
  88. # TODO: simplify javascript using ,ore than 1 class in the class attribute?
  89.  
  90. import datetime
  91. import StringIO
  92. import sys
  93. import time
  94. import unittest
  95. from xml.sax import saxutils
  96.  
  97. reload(sys)
  98. sys.setdefaultencoding('utf8')
  99.  
  100. # ------------------------------------------------------------------------
  101. # The redirectors below are used to capture output during testing. Output
  102. # sent to sys.stdout and sys.stderr are automatically captured. However
  103. # in some cases sys.stdout is already cached before HTMLTestRunner is
  104. # invoked (e.g. calling logging.basicConfig). In order to capture those
  105. # output, use the redirectors for the cached stream.
  106. #
  107. # e.g.
  108. # >>> logging.basicConfig(stream=HTMLTestRunner.stdout_redirector)
  109. # >>>
  110.  
  111. class OutputRedirector(object):
  112. """ Wrapper to redirect stdout or stderr """
  113. def __init__(self, fp):
  114. self.fp = fp
  115.  
  116. def write(self, s):
  117. self.fp.write(s)
  118.  
  119. def writelines(self, lines):
  120. self.fp.writelines(lines)
  121.  
  122. def flush(self):
  123. self.fp.flush()
  124.  
  125. stdout_redirector = OutputRedirector(sys.stdout)
  126. stderr_redirector = OutputRedirector(sys.stderr)
  127.  
  128. # ----------------------------------------------------------------------
  129. # Template
  130.  
  131. class Template_mixin(object):
  132. """
  133. Define a HTML template for report customerization and generation.
  134.  
  135. Overall structure of an HTML report
  136.  
  137. HTML
  138. +------------------------+
  139. |<html> |
  140. | <head> |
  141. | |
  142. | STYLESHEET |
  143. | +----------------+ |
  144. | | | |
  145. | +----------------+ |
  146. | |
  147. | </head> |
  148. | |
  149. | <body> |
  150. | |
  151. | HEADING |
  152. | +----------------+ |
  153. | | | |
  154. | +----------------+ |
  155. | |
  156. | REPORT |
  157. | +----------------+ |
  158. | | | |
  159. | +----------------+ |
  160. | |
  161. | ENDING |
  162. | +----------------+ |
  163. | | | |
  164. | +----------------+ |
  165. | |
  166. | </body> |
  167. |</html> |
  168. +------------------------+
  169. """
  170.  
  171. STATUS = {
  172. 0: 'Pass',
  173. 1: 'Fail',
  174. 2: 'Error',
  175. }
  176.  
  177. DEFAULT_TITLE = 'Unit Test Report'
  178. DEFAULT_DESCRIPTION = ''
  179.  
  180. # ------------------------------------------------------------------------
  181. # HTML Template
  182.  
  183. HTML_TMPL = r"""<?xml version="1.0" encoding="UTF-8"?>
  184. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  185. <html xmlns="http://www.w3.org/1999/xhtml">
  186. <head>
  187. <title>%(title)s</title>
  188. <meta name="generator" content="%(generator)s"/>
  189. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  190. %(stylesheet)s
  191. </head>
  192. <body>
  193. <script language="javascript" type="text/javascript"><!--
  194. output_list = Array();
  195.  
  196. /* level - 0:Summary; 1:Failed; 2:All */
  197. function showCase(level) {
  198. trs = document.getElementsByTagName("tr");
  199. for (var i = 0; i < trs.length; i++) {
  200. tr = trs[i];
  201. id = tr.id;
  202. if (id.substr(0,2) == 'ft') {
  203. if (level < 1) {
  204. tr.className = 'hiddenRow';
  205. }
  206. else {
  207. tr.className = '';
  208. }
  209. }
  210. if (id.substr(0,2) == 'pt') {
  211. if (level > 1) {
  212. tr.className = '';
  213. }
  214. else {
  215. tr.className = 'hiddenRow';
  216. }
  217. }
  218. }
  219. }
  220.  
  221. function showClassDetail(cid, count) {
  222. var id_list = Array(count);
  223. var toHide = 1;
  224. for (var i = 0; i < count; i++) {
  225. tid0 = 't' + cid.substr(1) + '.' + (i+1);
  226. tid = 'f' + tid0;
  227. tr = document.getElementById(tid);
  228. if (!tr) {
  229. tid = 'p' + tid0;
  230. tr = document.getElementById(tid);
  231. }
  232. id_list[i] = tid;
  233. if (tr.className) {
  234. toHide = 0;
  235. }
  236. }
  237. for (var i = 0; i < count; i++) {
  238. tid = id_list[i];
  239. if (toHide) {
  240. document.getElementById('div_'+tid).style.display = 'none'
  241. document.getElementById(tid).className = 'hiddenRow';
  242. }
  243. else {
  244. document.getElementById(tid).className = '';
  245. }
  246. }
  247. }
  248.  
  249. function showTestDetail(div_id){
  250. var details_div = document.getElementById(div_id)
  251. var displayState = details_div.style.display
  252. // alert(displayState)
  253. if (displayState != 'block' ) {
  254. displayState = 'block'
  255. details_div.style.display = 'block'
  256. }
  257. else {
  258. details_div.style.display = 'none'
  259. }
  260. }
  261.  
  262. function html_escape(s) {
  263. s = s.replace(/&/g,'&amp;');
  264. s = s.replace(/</g,'&lt;');
  265. s = s.replace(/>/g,'&gt;');
  266. return s;
  267. }
  268.  
  269. /* obsoleted by detail in <div>
  270. function showOutput(id, name) {
  271. var w = window.open("", //url
  272. name,
  273. "resizable,scrollbars,status,width=800,height=450");
  274. d = w.document;
  275. d.write("<pre>");
  276. d.write(html_escape(output_list[id]));
  277. d.write("\n");
  278. d.write("<a href='javascript:window.close()'>close</a>\n");
  279. d.write("</pre>\n");
  280. d.close();
  281. }
  282. */
  283. --></script>
  284.  
  285. %(heading)s
  286. %(report)s
  287. %(ending)s
  288.  
  289. </body>
  290. </html>
  291. """
  292. # variables: (title, generator, stylesheet, heading, report, ending)
  293.  
  294. # ------------------------------------------------------------------------
  295. # Stylesheet
  296. #
  297. # alternatively use a <link> for external style sheet, e.g.
  298. # <link rel="stylesheet" href="$url" type="text/css">
  299.  
  300. STYLESHEET_TMPL = """
  301. <style type="text/css" media="screen">
  302. body { font-family: verdana, arial, helvetica, sans-serif; font-size: 80%; }
  303. table { font-size: 100%; }
  304. pre { }
  305.  
  306. /* -- heading ---------------------------------------------------------------------- */
  307. h1 {
  308. font-size: 16pt;
  309. color: gray;
  310. }
  311. .heading {
  312. margin-top: 0ex;
  313. margin-bottom: 1ex;
  314. }
  315.  
  316. .heading .attribute {
  317. margin-top: 1ex;
  318. margin-bottom: 0;
  319. }
  320.  
  321. .heading .description {
  322. margin-top: 4ex;
  323. margin-bottom: 6ex;
  324. }
  325.  
  326. /* -- css div popup ------------------------------------------------------------------------ */
  327. a.popup_link {
  328. }
  329.  
  330. a.popup_link:hover {
  331. color: red;
  332. }
  333.  
  334. .popup_window {
  335. display: none;
  336. position: relative;
  337. left: 0px;
  338. top: 0px;
  339. /*border: solid #627173 1px; */
  340. padding: 10px;
  341. background-color: #E6E6D6;
  342. font-family: "Lucida Console", "Courier New", Courier, monospace;
  343. text-align: left;
  344. font-size: 8pt;
  345. width: 500px;
  346. }
  347.  
  348. }
  349. /* -- report ------------------------------------------------------------------------ */
  350. #show_detail_line {
  351. margin-top: 3ex;
  352. margin-bottom: 1ex;
  353. }
  354. #result_table {
  355. width: 80%;
  356. border-collapse: collapse;
  357. border: 1px solid #777;
  358. }
  359. #header_row {
  360. font-weight: bold;
  361. color: white;
  362. background-color: #777;
  363. }
  364. #result_table td {
  365. border: 1px solid #777;
  366. padding: 2px;
  367. }
  368. #total_row { font-weight: bold; }
  369. .passClass { background-color: #6c6; }
  370. .failClass { background-color: #c60; }
  371. .errorClass { background-color: #c00; }
  372. .passCase { color: #6c6; }
  373. .failCase { color: #c60; font-weight: bold; }
  374. .errorCase { color: #c00; font-weight: bold; }
  375. .hiddenRow { display: none; }
  376. .testcase { margin-left: 2em; }
  377.  
  378. /* -- ending ---------------------------------------------------------------------- */
  379. #ending {
  380. }
  381.  
  382. </style>
  383. """
  384.  
  385. # ------------------------------------------------------------------------
  386. # Heading
  387. #
  388.  
  389. HEADING_TMPL = """<div class='heading'>
  390. <h1>%(title)s</h1>
  391. %(parameters)s
  392. <p class='description'>%(description)s</p>
  393. </div>
  394.  
  395. """ # variables: (title, parameters, description)
  396.  
  397. HEADING_ATTRIBUTE_TMPL = """<p class='attribute'><strong>%(name)s:</strong> %(value)s</p>
  398. """ # variables: (name, value)
  399.  
  400. # ------------------------------------------------------------------------
  401. # Report
  402. #
  403.  
  404. REPORT_TMPL = """
  405. <p id='show_detail_line'>Show
  406. <a href='javascript:showCase(0)'>Summary</a>
  407. <a href='javascript:showCase(1)'>Failed</a>
  408. <a href='javascript:showCase(2)'>All</a>
  409. </p>
  410. <table id='result_table'>
  411. <colgroup>
  412. <col align='left' />
  413. <col align='right' />
  414. <col align='right' />
  415. <col align='right' />
  416. <col align='right' />
  417. <col align='right' />
  418. </colgroup>
  419. <tr id='header_row'>
  420. <td>Test Group/Test case</td>
  421. <td>Count</td>
  422. <td>Pass</td>
  423. <td>Fail</td>
  424. <td>Error</td>
  425. <td>View</td>
  426. </tr>
  427. %(test_list)s
  428. <tr id='total_row'>
  429. <td>Total</td>
  430. <td>%(count)s</td>
  431. <td>%(Pass)s</td>
  432. <td>%(fail)s</td>
  433. <td>%(error)s</td>
  434. <td>&nbsp;</td>
  435. </tr>
  436. </table>
  437. """ # variables: (test_list, count, Pass, fail, error)
  438.  
  439. REPORT_CLASS_TMPL = r"""
  440. <tr class='%(style)s'>
  441. <td>%(desc)s</td>
  442. <td>%(count)s</td>
  443. <td>%(Pass)s</td>
  444. <td>%(fail)s</td>
  445. <td>%(error)s</td>
  446. <td><a href="javascript:showClassDetail('%(cid)s',%(count)s)">Detail</a></td>
  447. </tr>
  448. """ # variables: (style, desc, count, Pass, fail, error, cid)
  449.  
  450. REPORT_TEST_WITH_OUTPUT_TMPL = r"""
  451. <tr id='%(tid)s' class='%(Class)s'>
  452. <td class='%(style)s'><div class='testcase'>%(desc)s</div></td>
  453. <td colspan='5' align='center'>
  454.  
  455. <!--css div popup start-->
  456. <a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_%(tid)s')" >
  457. %(status)s</a>
  458.  
  459. <div id='div_%(tid)s' class="popup_window">
  460. <div style='text-align: right; color:red;cursor:pointer'>
  461. <a onfocus='this.blur();' onclick="document.getElementById('div_%(tid)s').style.display = 'none' " >
  462. [x]</a>
  463. </div>
  464. <pre>
  465. %(script)s
  466. </pre>
  467. </div>
  468. <!--css div popup end-->
  469.  
  470. </td>
  471. </tr>
  472. """ # variables: (tid, Class, style, desc, status)
  473.  
  474. REPORT_TEST_NO_OUTPUT_TMPL = r"""
  475. <tr id='%(tid)s' class='%(Class)s'>
  476. <td class='%(style)s'><div class='testcase'>%(desc)s</div></td>
  477. <td colspan='5' align='center'>%(status)s</td>
  478. </tr>
  479. """ # variables: (tid, Class, style, desc, status)
  480.  
  481. REPORT_TEST_OUTPUT_TMPL = r"""
  482. %(id)s: %(output)s
  483. """ # variables: (id, output)
  484.  
  485. # ------------------------------------------------------------------------
  486. # ENDING
  487. #
  488.  
  489. ENDING_TMPL = """<div id='ending'>&nbsp;</div>"""
  490.  
  491. # -------------------- The end of the Template class -------------------
  492.  
  493. TestResult = unittest.TestResult
  494.  
  495. class _TestResult(TestResult):
  496. # note: _TestResult is a pure representation of results.
  497. # It lacks the output and reporting ability compares to unittest._TextTestResult.
  498.  
  499. def __init__(self, verbosity=1):
  500. TestResult.__init__(self)
  501. self.stdout0 = None
  502. self.stderr0 = None
  503. self.success_count = 0
  504. self.failure_count = 0
  505. self.error_count = 0
  506. self.verbosity = verbosity
  507.  
  508. # result is a list of result in 4 tuple
  509. # (
  510. # result code (0: success; 1: fail; 2: error),
  511. # TestCase object,
  512. # Test output (byte string),
  513. # stack trace,
  514. # )
  515. self.result = []
  516.  
  517. def startTest(self, test):
  518. TestResult.startTest(self, test)
  519. # just one buffer for both stdout and stderr
  520. self.outputBuffer = StringIO.StringIO()
  521. stdout_redirector.fp = self.outputBuffer
  522. stderr_redirector.fp = self.outputBuffer
  523. self.stdout0 = sys.stdout
  524. self.stderr0 = sys.stderr
  525. sys.stdout = stdout_redirector
  526. sys.stderr = stderr_redirector
  527.  
  528. def complete_output(self):
  529. """
  530. Disconnect output redirection and return buffer.
  531. Safe to call multiple times.
  532. """
  533. if self.stdout0:
  534. sys.stdout = self.stdout0
  535. sys.stderr = self.stderr0
  536. self.stdout0 = None
  537. self.stderr0 = None
  538. return self.outputBuffer.getvalue()
  539.  
  540. def stopTest(self, test):
  541. # Usually one of addSuccess, addError or addFailure would have been called.
  542. # But there are some path in unittest that would bypass this.
  543. # We must disconnect stdout in stopTest(), which is guaranteed to be called.
  544. self.complete_output()
  545.  
  546. def addSuccess(self, test):
  547. self.success_count += 1
  548. TestResult.addSuccess(self, test)
  549. output = self.complete_output()
  550. self.result.append((0, test, output, ''))
  551. if self.verbosity > 1:
  552. sys.stderr.write('ok ')
  553. sys.stderr.write(str(test))
  554. sys.stderr.write('\n')
  555. else:
  556. sys.stderr.write('.')
  557.  
  558. def addError(self, test, err):
  559. self.error_count += 1
  560. TestResult.addError(self, test, err)
  561. _, _exc_str = self.errors[-1]
  562. output = self.complete_output()
  563. self.result.append((2, test, output, _exc_str))
  564. if self.verbosity > 1:
  565. sys.stderr.write('E ')
  566. sys.stderr.write(str(test))
  567. sys.stderr.write('\n')
  568. else:
  569. sys.stderr.write('E')
  570.  
  571. def addFailure(self, test, err):
  572. self.failure_count += 1
  573. TestResult.addFailure(self, test, err)
  574. _, _exc_str = self.failures[-1]
  575. output = self.complete_output()
  576. self.result.append((1, test, output, _exc_str))
  577. if self.verbosity > 1:
  578. sys.stderr.write('F ')
  579. sys.stderr.write(str(test))
  580. sys.stderr.write('\n')
  581. else:
  582. sys.stderr.write('F')
  583.  
  584. class HTMLTestRunner(Template_mixin):
  585. """
  586. """
  587. def __init__(self, stream=sys.stdout, verbosity=1, title=None, description=None):
  588. self.stream = stream
  589. self.verbosity = verbosity
  590. if title is None:
  591. self.title = self.DEFAULT_TITLE
  592. else:
  593. self.title = title
  594. if description is None:
  595. self.description = self.DEFAULT_DESCRIPTION
  596. else:
  597. self.description = description
  598.  
  599. self.startTime = datetime.datetime.now()
  600.  
  601. def run(self, test):
  602. "Run the given test case or test suite."
  603. result = _TestResult(self.verbosity)
  604. test(result)
  605. self.stopTime = datetime.datetime.now()
  606. self.generateReport(test, result)
  607. print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
  608. return result
  609.  
  610. def sortResult(self, result_list):
  611. # unittest does not seems to run in any particular order.
  612. # Here at least we want to group them together by class.
  613. rmap = {}
  614. classes = []
  615. for n,t,o,e in result_list:
  616. cls = t.__class__
  617. if not rmap.has_key(cls):
  618. rmap[cls] = []
  619. classes.append(cls)
  620. rmap[cls].append((n,t,o,e))
  621. r = [(cls, rmap[cls]) for cls in classes]
  622. return r
  623.  
  624. def getReportAttributes(self, result):
  625. """
  626. Return report attributes as a list of (name, value).
  627. Override this to add custom attributes.
  628. """
  629. startTime = str(self.startTime)[:19]
  630. duration = str(self.stopTime - self.startTime)
  631. status = []
  632. if result.success_count: status.append('Pass %s' % result.success_count)
  633. if result.failure_count: status.append('Failure %s' % result.failure_count)
  634. if result.error_count: status.append('Error %s' % result.error_count )
  635. if status:
  636. status = ' '.join(status)
  637. else:
  638. status = 'none'
  639. return [
  640. ('Start Time', startTime),
  641. ('Duration', duration),
  642. ('Status', status),
  643. ]
  644.  
  645. def generateReport(self, test, result):
  646. report_attrs = self.getReportAttributes(result)
  647. generator = 'HTMLTestRunner %s' % __version__
  648. stylesheet = self._generate_stylesheet()
  649. heading = self._generate_heading(report_attrs)
  650. report = self._generate_report(result)
  651. ending = self._generate_ending()
  652. output = self.HTML_TMPL % dict(
  653. title = saxutils.escape(self.title),
  654. generator = generator,
  655. stylesheet = stylesheet,
  656. heading = heading,
  657. report = report,
  658. ending = ending,
  659. )
  660. self.stream.write(output.encode('utf8'))
  661.  
  662. def _generate_stylesheet(self):
  663. return self.STYLESHEET_TMPL
  664.  
  665. def _generate_heading(self, report_attrs):
  666. a_lines = []
  667. for name, value in report_attrs:
  668. line = self.HEADING_ATTRIBUTE_TMPL % dict(
  669. name = saxutils.escape(name),
  670. value = saxutils.escape(value),
  671. )
  672. a_lines.append(line)
  673. heading = self.HEADING_TMPL % dict(
  674. title = saxutils.escape(self.title),
  675. parameters = ''.join(a_lines),
  676. description = saxutils.escape(self.description),
  677. )
  678. return heading
  679.  
  680. def _generate_report(self, result):
  681. rows = []
  682. sortedResult = self.sortResult(result.result)
  683. for cid, (cls, cls_results) in enumerate(sortedResult):
  684. # subtotal for a class
  685. np = nf = ne = 0
  686. for n,t,o,e in cls_results:
  687. if n == 0: np += 1
  688. elif n == 1: nf += 1
  689. else: ne += 1
  690.  
  691. # format class description
  692. if cls.__module__ == "__main__":
  693. name = cls.__name__
  694. else:
  695. name = "%s.%s" % (cls.__module__, cls.__name__)
  696. doc = cls.__doc__ and cls.__doc__.split("\n")[0] or ""
  697. desc = doc and '%s: %s' % (name, doc) or name
  698.  
  699. row = self.REPORT_CLASS_TMPL % dict(
  700. style = ne > 0 and 'errorClass' or nf > 0 and 'failClass' or 'passClass',
  701. desc = desc,
  702. count = np+nf+ne,
  703. Pass = np,
  704. fail = nf,
  705. error = ne,
  706. cid = 'c%s' % (cid+1),
  707. )
  708. rows.append(row)
  709.  
  710. for tid, (n,t,o,e) in enumerate(cls_results):
  711. self._generate_report_test(rows, cid, tid, n, t, o, e)
  712.  
  713. report = self.REPORT_TMPL % dict(
  714. test_list = ''.join(rows),
  715. count = str(result.success_count+result.failure_count+result.error_count),
  716. Pass = str(result.success_count),
  717. fail = str(result.failure_count),
  718. error = str(result.error_count),
  719. )
  720. return report
  721.  
  722. def _generate_report_test(self, rows, cid, tid, n, t, o, e):
  723. # e.g. 'pt1.1', 'ft1.1', etc
  724. has_output = bool(o or e)
  725. tid = (n == 0 and 'p' or 'f') + 't%s.%s' % (cid+1,tid+1)
  726. name = t.id().split('.')[-1]
  727. doc = t.shortDescription() or ""
  728. desc = doc and ('%s: %s' % (name, doc)) or name
  729. tmpl = has_output and self.REPORT_TEST_WITH_OUTPUT_TMPL or self.REPORT_TEST_NO_OUTPUT_TMPL
  730.  
  731. # o and e should be byte string because they are collected from stdout and stderr?
  732. if isinstance(o,str):
  733. # TODO: some problem with 'string_escape': it escape \n and mess up formating
  734. # uo = unicode(o.encode('string_escape'))
  735. uo = o.decode('latin-1')
  736. else:
  737. uo = o
  738. if isinstance(e,str):
  739. # TODO: some problem with 'string_escape': it escape \n and mess up formating
  740. # ue = unicode(e.encode('string_escape'))
  741. ue = e.decode('latin-1')
  742. else:
  743. ue = e
  744.  
  745. script = self.REPORT_TEST_OUTPUT_TMPL % dict(
  746. id = tid,
  747. output = saxutils.escape(uo+ue),
  748. )
  749.  
  750. row = tmpl % dict(
  751. tid = tid,
  752. Class = (n == 0 and 'hiddenRow' or 'none'),
  753. style = n == 2 and 'errorCase' or (n == 1 and 'failCase' or 'none'),
  754. desc = desc,
  755. script = script,
  756. status = self.STATUS[n],
  757. )
  758. rows.append(row)
  759. if not has_output:
  760. return
  761.  
  762. def _generate_ending(self):
  763. return self.ENDING_TMPL
  764.  
  765. ##############################################################################
  766. # Facilities for running tests from the command line
  767. ##############################################################################
  768.  
  769. # Note: Reuse unittest.TestProgram to launch test. In the future we may
  770. # build our own launcher to support more specific command line
  771. # parameters like test title, CSS, etc.
  772. class TestProgram(unittest.TestProgram):
  773. """
  774. A variation of the unittest.TestProgram. Please refer to the base
  775. class for command line parameters.
  776. """
  777. def runTests(self):
  778. # Pick HTMLTestRunner as the default test runner.
  779. # base class's testRunner parameter is not useful because it means
  780. # we have to instantiate HTMLTestRunner before we know self.verbosity.
  781. if self.testRunner is None:
  782. self.testRunner = HTMLTestRunner(verbosity=self.verbosity)
  783. unittest.TestProgram.runTests(self)
  784.  
  785. main = TestProgram
  786.  
  787. ##############################################################################
  788. # Executing this module from the command line
  789. ##############################################################################
  790.  
  791. if __name__ == "__main__":
  792. main(module=None)

configrunmode.py

  1. # -*- coding:utf-8 -*-
  2.  
  3. import configparser
  4.  
  5. class ConfigRunMode:
  6. def __init__(self, run_case_config_file):
  7. config = configparser.ConfigParser()
  8. # 从配置文件中读取运行模式
  9. config.read(run_case_config_file)
  10. try:
  11. self.run_mode = config['RUNCASECONFIG']['run_mode']
  12. self.run_mode = int(self.run_mode)
  13. self.excel_name = config['RUNCASECONFIG']['excel_name']
  14. self.sheet_list = config['RUNCASECONFIG']['sheet_list']
  15. self.case_list = config['RUNCASECONFIG']['case_list']
  16. self.case_list = eval(self.case_list) # 把字符串类型的list转换为list
  17. self.sheet_list = eval(self.sheet_list) # 同上
  18. except Exception as e:
  19. print('%s', e)
  20.  
  21. def get_run_mode(self):
  22. return self.run_mode
  23.  
  24. def get_case_list(self):
  25. return self.case_list
  26.  
  27. def get_sheet_list(self):
  28. return self.sheet_list
  29.  
  30. def get_excel_name(self):
  31. return self.excel_name

utf-8递归编码:

  1. # -*- coding:utf-8 -*-
  2.  
  3. def unicode_convert(input):
  4. if isinstance(input, dict):
  5. return {unicode_convert(key): unicode_convert(value) for key, value in input.iteritems()}
  6. elif isinstance(input, list):
  7. return [unicode_convert(element) for element in input]
  8. elif isinstance(input, unicode):
  9. return input.encode('utf-8')
  10. else:
  11. return input
  12.  
  13. if __name__=="__main__":
  14. input = ['\\u6355\\u9c7c\\u6bd4\\u8d5b', '\\u8109\\u8109', '\\u7f8e\\u7f8e\\u7bb1', '\\u9b54buy\\u5546\\u57ce',
  15. '\\u9b54\\u7b1b\\u6298\\u4e0a\\u6298', '\\u53ef\\u5f97\\u773c\\u955c', '\\u5c48\\u81e3\\u6c0f', '\\u4f18\\u9009',
  16. '\\u5168\\u6c11\\u4f18\\u60e0', '\\u5c1a\\u54c1\\u7f51', '\\u826f\\u4ed3', '\\u624b\\u673a\\u5929\\u732b',
  17. '\\u60e0\\u55b5', '\\u60e0\\u54c1\\u6298', '\\u62cd\\u56fe\\u8d2d']
  18. result = unicode_convert(input)
  19. print result

globalconfig.py

  1. # -*- coding:utf-8 -*-
  2.  
  3. from configrunmode import ConfigRunMode
  4.  
  5. class Global(object):
  6. def __init__(self):
  7. # 读取运行模式配置
  8. self.run_mode_config = ConfigRunMode(r'E:\NewSearchApiTest\NewSearch\config\run_case_config.ini')
  9.  
  10. # 获取运行模式配置
  11. def get_run_mode(self):
  12. return self.run_mode_config.get_run_mode()
  13.  
  14. # 获取需要运行的excel
  15. def get_run_excel_name(self):
  16. return self.run_mode_config.get_excel_name()
  17.  
  18. # 获取需要单独运行的用例列表
  19. def get_run_case_list(self):
  20. return self.run_mode_config.get_case_list()
  21.  
  22. # 获取需要单独运行的sheet列表
  23. def get_run_sheet_list(self):
  24. return self.run_mode_config.get_sheet_list()

parse_excel.py

  1. # -*- coding:utf-8 -*-
  2. """从excel中获取请求参数,并返回结果"""
  3. import xlrd
  4. import os
  5. from collections import namedtuple
  6. from request_method import *
  7. from file_actions import *
  8. import json
  9. from element_encode import unicode_convert
  10.  
  11. col_name = ["CaseName", "API_Protocol", "Request_URL", "Request_Method", "Request_Data_Type", "Request_Data", "Check_Point", "Note", "Steps", "Action"]
  12. col_obj = namedtuple("col", col_name)
  13. col = col_obj(*(i for i in range(len(col_name))))
  14.  
  15. class ParseExcel(object):
  16. """从excel中获取请求参数"""
  17. def __init__(self, flag, excelName, tableName = None, caseName = None):
  18. self.excel_path = os.path.normpath(
  19. os.path.join(os.path.join(r'E:\NewSearchApiTest\data'), str(excelName)))
  20. self.excel_name = excelName
  21. self.table_name = tableName
  22. self.case_name = caseName
  23. self.flag = flag
  24.  
  25. def _get_table(self):
  26. """flag=1: 获取指定sheet页;flag=0: 获取所有sheet页"""
  27. excel = xlrd.open_workbook(self.excel_path)
  28. sheet_names = excel.sheet_names()
  29. if self.flag:
  30. if self.table_name in sheet_names:
  31. return self.table_name.split()
  32. else:
  33. raise ValueError("sheet {} not found in {}".format(self.table_name, self.excel_path))
  34. else:
  35. return sheet_names
  36.  
  37. def get_content(self):
  38. sheets = self._get_table()
  39. excel = xlrd.open_workbook(self.excel_path)
  40. for sheet in sheets:
  41. table = excel.sheet_by_name(sheet)
  42. line_num = table.nrows
  43. if line_num < 2:
  44. print ("The content of %s is null ! ")
  45. raise ValueError("the sheet content is null!")
  46. else:
  47. for i in range(1, line_num):
  48. line = table.row_values(i)
  49. if line == "":
  50. pass
  51. else:
  52. url = eval(json.dumps(line[col.Request_URL]).strip())
  53. pre_body = json.loads(line[col.Request_Data])
  54. request_method = line[col.Request_Method]
  55. data_type = line[col.Request_Data_Type]
  56. if self.flag == 0 or (self.flag and self.case_name == []): #获取所有用例数据 或者指定sheet页中的所有用例
  57. print "\n用例名称:", line[col.CaseName]
  58. print "用例说明:", line[col.Note]
  59. print "请求URL:", url
  60. resp_result = unicode_convert(request_methods(url, data_type, request_method, pre_body))
  61. print "返回结果:" , json.dumps(resp_result)
  62. check_point = line[col.Check_Point]
  63. write_data('checkfile.txt', line[col.CaseName], check_point)
  64. write_data('result.txt', line[col.CaseName], str(resp_result))
  65. continue
  66. elif self.flag:
  67. for case in self.case_name:
  68. if line[col.CaseName] == case: #获取指定用例的数据
  69. print "\n用例名称:", line[col.CaseName]
  70. print "用例说明:", line[col.Note]
  71. print "请求URL:", url
  72. resp_result = unicode_convert(request_methods(url, data_type, request_method, pre_body))
  73. print "返回结果:", json.dumps(resp_result)
  74. check_point = line[col.Check_Point]
  75. write_data('checkfile.txt', line[col.CaseName], check_point)
  76. write_data('result.txt', line[col.CaseName], str(resp_result))
  77. break
  78. # else:
  79. # if i == (line_num - 1):
  80. # raise ValueError("caseName: {} not found!".format(self.case_name))
  81.  
  82. if __name__ == '__main__':
  83. # 指定sheet页中指定case
  84. excel_object = ParseExcel(1, "test_case_excel.xlsx", tableName="Sheet1", caseName="card_recom_01")
  85.  
  86. #运行指定sheet页中的所有cases
  87. # excel_object = ParseExcel("test_case_excel.xlsx", tableName="Sheet1", flag=1)
  88.  
  89. # 运行所有sheet中的所有用例
  90. # excel_object = ParseExcel("test_case_excel.xlsx", flag=0)
  91. resp_list = excel_object.get_content()
  92. # print resp_list

parse_response.py

  1. # -*- coding:utf-8 -*-
  2.  
  3. from parse_excel import ParseExcel
  4. import json
  5. import collections
  6. import re
  7.  
  8. def adid_appid_list(case_name):
  9. tree = lambda: collections.defaultdict(tree)
  10. appid_adid_list = tree()
  11. with open(r'E:\NewSearchApiTest\NewSearch\tmp\result.txt', 'r') as f:
  12. for line in f.readlines():
  13. if line.split(":")[0] == case_name:
  14. appid_list = re.findall('\d+', str(re.findall("'appId': '\d+'", line)))
  15. adid_list = re.findall('\d+', str(re.findall("'adId': '\d+'", line)))
  16. appid_adid_list[case_name]['appid'] = appid_list
  17. appid_adid_list[case_name]['adid'] = adid_list
  18. # print json.dumps(appid_adid_list)
  19. return json.dumps(appid_adid_list), appid_list, adid_list
  20.  
  21. # if __name__=="__main__":
  22. # a, b, c = adid_appid_list('card_recom_05')
  23. # print a

request_method.py

  1. # -*- coding:utf-8 -*-
  2. # 请求并返回结果
  3. import json
  4. import requests
  5. import time
  6. from ads_merge_pb2 import *
  7. from google.protobuf.json_format import MessageToDict, ParseDict
  8.  
  9. def pbToBody(pre_body):
  10. req_body = json.dumps(pre_body)
  11. print '请求Body:' + req_body
  12. pbmsg = AdsRequest()
  13. ParseDict(js_dict=pre_body, message=pbmsg)
  14. boby = pbmsg.SerializeToString()
  15. return boby
  16.  
  17. def covertrespb2dict(res):
  18. respb = AdsResponse()
  19. respb.ParseFromString(res)
  20. return MessageToDict(respb)
  21.  
  22. def request_methods(url, data_type, request_method, pre_body):
  23. body = pre_body
  24. if data_type == "json":
  25. header = {
  26. 'Content-Type': 'application/json;charset=utf-8 '
  27. }
  28. elif data_type == "pb":
  29. header = {
  30. 'Content-Type': 'application/x-protostuff;charset=UTF-8'
  31. }
  32. body = pbToBody(pre_body)
  33. elif data_type == "x-java":
  34. header = {
  35. 'Content-Type': 'application/x-java-serialized-object'
  36. }
  37. if request_method == "post":
  38. resp = requests.post(url, data=body, headers=header, verify=False)
  39. else:
  40. resp = requests.get(url, data=json.dumps(body), headers=header, verify=False)
  41. time.sleep(0.2)
  42. result2 = resp.content
  43. print resp.status_code
  44. if data_type == "pb":
  45. resp = covertrespb2dict(result2)
  46. if data_type == "Json":
  47. resp = json.loads(json.dumps(result2, ensure_ascii=False, indent=4))
  48. return resp

run_cases.py

  1. # -*- coding:utf-8 -*-
  2.  
  3. from Search.common.parse_excel import ParseExcel
  4.  
  5. class RunCase(object):
  6. """# run_mode: 1: 获取指定sheet页;0: 获取所有sheet页"""
  7. def __init__(self, run_mode, run_excel_name, run_sheet_list, run_case_list):
  8. self.run_mode = run_mode
  9. self.run_excel_name = run_excel_name
  10. self.run_sheet_list = run_sheet_list
  11. self.run_case_list = run_case_list
  12.  
  13. def run_case(self):
  14. if self.run_mode == 0: # 获取所有sheet页
  15. excel_object = ParseExcel(self.run_mode, self.run_excel_name)
  16. if self.run_mode == 1:
  17. if self.run_case_list == "": # 运行指定sheet页的所有用例
  18. excel_object = ParseExcel(self.run_mode, self.run_excel_name, self.run_sheet_list)
  19. else:
  20. excel_object = ParseExcel(self.run_mode, self.run_excel_name, self.run_sheet_list, self.run_case_list)
  21. excel_object.get_content()

zookeeper.py

  1. # -*- coding: utf-8 -*-
  2. import json
  3. import sys
  4. import time
  5. from kazoo.client import KazooClient,KazooState
  6. import logging
  7. logging.basicConfig(
  8. level=logging.DEBUG
  9. ,stream=sys.stdout
  10. ,format='%(asctime)s %(pathname)s %(funcName)s%(lineno)d %(levelname)s: %(message)s')
  11.  
  12. biz_config_path='${路经}'
  13.  
  14. def get_full_config_path(app,config_item):
  15. return biz_config_path+'/'+app+'/'+config_item
  16.  
  17. class Ads_Zk_Config_Client(object):
  18. def __init__(self, zk_connect_str='11.73.31.132:2181'):
  19. self.zk=KazooClient(hosts=zk_connect_str)
  20.  
  21. def getConfig(self,app=None,config_item=None):
  22. if ( app ) and (config_item):
  23. if not self.zk.connected:
  24. self.zk.start()
  25. data, stat = self.zk.get(get_full_config_path(app,config_item))
  26. return data
  27. else:
  28. print 'app or config_tiem is none'
  29. return None
  30.  
  31. def setConfig(self, app=None, config_item=None,value=None):
  32. if ( app ) and (config_item) and ( value):
  33. if not self.zk.connected:
  34. self.zk.start()
  35. self.zk.set(path=get_full_config_path(app,config_item),value=value)
  36. else:
  37. print 'app or config_tiem or value is none'
  38.  
  39. def close(self):
  40. if not self.zk.connected:
  41. self.zk.close();
  42.  
  43. def get_zk_config(host='11.73.31.132:2181',app=None,config_item=None):
  44. zk_client = Ads_Zk_Config_Client(zk_connect_str=host)
  45. data = zk_client.getConfig(app=app,config_item=config_item);
  46. zk_client.close()
  47. return data
  48.  
  49. def set_zk_config(host='11.73.31.132:2181',app=None,config_item=None,value=None):
  50. zk_client = Ads_Zk_Config_Client(zk_connect_str=host)
  51. data=zk_client.setConfig(app=app,config_item=config_item,value=value);
  52. zk_client.close()
  53. return data
  54.  
  55. def update_zk_config(app='sbid',configdict=None):
  56. if configdict:
  57. logging.debug(json.dumps(configdict))
  58. for k, v in configdict.items():
  59. if get_zk_config(app=app, config_item=k) != v:
  60. logging.debug(msg='before change config ' + get_zk_config(app=app,config_item=k))
  61. if type(v) == dict:
  62. v = json.dumps(v)
  63. set_zk_config(app=app, config_item=k, value=v)
  64. logging.debug(msg='set config ' + v)
  65. time.sleep(1)
  66. logging.debug(msg='final config ' + get_zk_config(app=app, config_item=k))
  67. else:
  68. logging.warn("config dice is None ,do not need change config")
  69.  
  70. if __name__ == '__main__':
  71. # print json.dumps(get_full_config_path(app='sbid',config_item='sbid-bs-default-h5-btn '))
  72.  
  73. config_value = get_zk_config(app='sbid',config_item='sbid-bs-default-h5-btn')
  74. # print json.dumps(config_value)

run_case_config.ini

  1. [RUNCASECONFIG]
  2. run_mode = 1
  3. excel_name = test_case_excel.xlsx
  4. sheet_list ="Sheet1"
  5. case_list = ['card_recom_03']

main.py

  1. # -*- coding:utf-8 -*-
  2. # 案例执行main脚本
  3. import os
  4. from Search.common.test_suit import *
  5. from Search.common.run_cases import RunCase
  6. from Search.common.globalconfig import Global
  7. from lib.HTMLTestRunner import *
  8. import unittest
  9.  
  10. if __name__=="__main__":
  11. # 全局配置
  12. global_config = Global()
  13. run_mode = global_config.get_run_mode() # 运行模式
  14. run_excel_name = global_config.get_run_excel_name() # 获取 excel文件名
  15. run_sheet_list = global_config.get_run_sheet_list() # 获取需要运行的sheet页列表
  16. run_case_list = global_config.get_run_case_list() # 需要运行的用例列表
  17.  
  18. # 删除临时文件
  19. if os.path.isfile(r'E:\NewSearchApiTest\NewSearch\tmp\result.txt') and os.path.isfile(r'E:\NewSearchApiTest\NewSearch\tmp\checkfile.txt'):
  20. os.remove(r'E:\NewSearchApiTest\NewSearch\tmp\result.txt')
  21. os.remove(r'E:\NewSearchApiTest\NewSearch\tmp\checkfile.txt')
  22.  
  23. #运行测试用例
  24. case_runner = RunCase(run_mode, run_excel_name, run_sheet_list, run_case_list)
  25. case_runner.run_case()
  26. suite = unittest.makeSuite(CheckPoint)
  27. path = r'E:\NewSearchApiTest\report'
  28. filename = os.path.join(path, 'CheckPoint.html')
  29. fp = file(filename, 'wb')
  30. runner = HTMLTestRunner(stream=fp, title=u'XXXXX', description=u'模块:XXXXX')
  31. runner.run(suite)
  32. fp.close()

Python+unittest+excel的更多相关文章

  1. Python unittest excel数据驱动

    安装xlrd 下载地址:https://pypi.python.org/pypi/xlrd 安装ddt 下载地址:https://pypi.python.org/pypi/ddt/1.1.0 clas ...

  2. python Unittest+excel+ddt数据驱动测试

    #!user/bin/env python # coding=utf- # @Author : Dang # @Time : // : # @Email : @qq.com # @File : # @ ...

  3. Python unittest excel数据驱动 写入

    之前写过一篇关于获取excel数据进行迭代的方法,今天补充上写入的方法.由于我用的是Python3,不兼容xlutils,所以无法使用copy excel的方式来写入.这里使用xlwt3创建excel ...

  4. Python导出Excel为Lua/Json/Xml实例教程(三):终极需求

    相关链接: Python导出Excel为Lua/Json/Xml实例教程(一):初识Python Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验 Python导出E ...

  5. Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验

    Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验 相关链接: Python导出Excel为Lua/Json/Xml实例教程(一):初识Python Python导出E ...

  6. Python导出Excel为Lua/Json/Xml实例教程(一):初识Python

    Python导出Excel为Lua/Json/Xml实例教程(一):初识Python 相关链接: Python导出Excel为Lua/Json/Xml实例教程(一):初识Python Python导出 ...

  7. python读取excel一例-------从工资表逐行提取信息

    在工作中经常要用到python操作excel,比如笔者公司中一个人事MM在发工资单的时候,需要从几百行的excel表中逐条的粘出信息,然后逐个的发送到员工的邮箱中.人事MM对此事不胜其烦,终于在某天请 ...

  8. 使用Python将Excel中的数据导入到MySQL

    使用Python将Excel中的数据导入到MySQL 工具 Python 2.7 xlrd MySQLdb 安装 Python 对于不同的系统安装方式不同,Windows平台有exe安装包,Ubunt ...

  9. 使用Python对Excel表格进行简单的读写操作(xlrd/xlwt)

    算是一个小技巧吧,只是进行一些简单的读写操作.让人不爽的是xlrd和xlwt是相对独立的,两个模块的对象不能通用,读写无法连贯操作,只能单独读.单独写,尚不知道如何解决. #①xlrd(读) #cod ...

随机推荐

  1. etc/sudoers配置文件详解-(转自xoker)

    从编写 sudo 配置文件/etc/sudoers开始: sudo的配置文件是/etc/sudoers ,我们可以用他的专用编辑工具visodu ,此工具的好处是在添加规则不太准确时,保存退出时会提示 ...

  2. CentOS 7 网络配置详解

    今天在一台PC上安装了CentOS 7,当时选择了最小安装模式,安装完成后马上用ifconfig查看本机的ip地址(局域网已经有DHCP),发现报错,提示ifconfig命令没找到. ? 1 2 3 ...

  3. Springboot2.x入门——helloWorld

    Springboot2.x入门--helloWorld 一.简介 1.1 Springboot简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的 ...

  4. java和kotlin的可见性修饰符对比

    private 意味着只在这个类内部(包含其所有成员)可见: protected-- 和 private一样 + 在子类中可见. internal -- 能见到类声明的 本模块内 的任何客户端都可见其 ...

  5. [论文阅读笔记] Are Meta-Paths Necessary, Revisiting Heterogeneous Graph Embeddings

    [论文阅读笔记] Are Meta-Paths Necessary? Revisiting Heterogeneous Graph Embeddings 本文结构 解决问题 主要贡献 算法原理 参考文 ...

  6. 西门子 S7-200 通过以太网通讯模块连接MCGS 通讯

    北京华科远创科技有限研发的远创智控ETH-YC模块,以太网通讯模块型号有MPI-ETH-YC01和PPI-ETH-YC01,适用于西门子S7-200/S7-300/S7-400.SMART S7-20 ...

  7. [翻译] 预览 C# 10 的新东西

    原文: [Introducing C# 10] 作者: Ken Bonny ​ 本周早些时候(译注:原文发表于5月1日),我关注了 Mads Torgersen 在 DotNet SouthWest ...

  8. ThinkPHP 全局异常处理

    wqy的笔记:http://www.upwqy.com/details/273.html 在thinkphp6 和 thinkphp5 全局异常处理 稍有不同 ThinkPHP6 在 tp6 中 框架 ...

  9. CVPR 2020目标跟踪多篇开源论文(下)

    CVPR 2020目标跟踪多篇开源论文(下) 6. Cooling-Shrinking Attack: Blinding the Tracker with Imperceptible Noises 作 ...

  10. NVIDIA Turing Architecture架构设计(上)

    NVIDIA Turing Architecture架构设计(上) 在游戏市场持续增长和对更好的 3D 图形的永不满足的需求的推动下, NVIDIA 已经将 GPU 发展成为许多计算密集型应用的世界领 ...