{"id":397,"date":"2010-07-18T20:52:06","date_gmt":"2010-07-19T01:52:06","guid":{"rendered":"http:\/\/www.insomnihack.com\/?p=397"},"modified":"2010-08-06T12:55:21","modified_gmt":"2010-08-06T17:55:21","slug":"run-coverage-py-under-pycharm","status":"publish","type":"post","link":"http:\/\/www.insomnihack.com\/?p=397","title":{"rendered":"Run Coverage.py under PyCharm"},"content":{"rendered":"<p><a href=\"http:\/\/www.jetbrains.com\/pycharm\/index.html\">PyCharm<\/a>&#8216;s test runner does not currently support running Ned Batchelder&#8217;s excellent Python code coverage tool <a href=\"http:\/\/nedbatchelder.com\/code\/coverage\/\">coverage.py<\/a>. While this may be addressed before final release, you can easily set up a run\/debug configuration manually to get the same effect. From within PyCharm, select the <em>Run -&gt; Edition Configurations<\/em> menu item.<\/p>\n<div id=\"attachment_398\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.insomnihack.com\/wp-content\/uploads\/coverage_config.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-398\" class=\"size-medium wp-image-398\" title=\"Coverage.py Configuration\" src=\"http:\/\/www.insomnihack.com\/wp-content\/uploads\/coverage_config-300x172.png\" alt=\"Coverage.py Configuration\" width=\"300\" height=\"172\" srcset=\"http:\/\/www.insomnihack.com\/wp-content\/uploads\/coverage_config-300x172.png 300w, http:\/\/www.insomnihack.com\/wp-content\/uploads\/coverage_config.png 685w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-398\" class=\"wp-caption-text\">Coverage.py Configuration<\/p><\/div>\n<p>In the <em>Run\/Debug Configurations<\/em> dialog, click the box with the plus sign in the upper right corner to create a new Python script configuration. Call the configuration whatever you want. I tend to run coverage.py as part of <a href=\"https:\/\/code.google.com\/p\/python-nose\/\">nose<\/a>, so I enter the path to the <tt>nosetests-script.py<\/tt> on my file system in the <em>Script<\/em> field. Under Windows, this will be in the Scripts sub-directory of your Python installation directory. If you&#8217;re on Linux or OSX, you can use the <tt>nose\/core.py<\/tt> file in your <tt>site-packages<\/tt> folder.<\/p>\n<p>In the <em>Script parameters<\/em> field, I enter the <tt>--with-coverage<\/tt> and <tt>--cover-package<\/tt> command line parameters. Finally, in the Working directory field, I add the path to the directory containing my unit tests. Running this configuration executes code coverage on my unit test directory, and PyCharm is smart enough to recognize any stack traces that may occur during the run, providing click-able links to the offending lines of code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PyCharm&#8216;s test runner does not currently support running Ned Batchelder&#8217;s excellent Python code coverage tool coverage.py. While this may be addressed before final release, you can easily set up a run\/debug configuration manually to get the same effect. From within PyCharm, select the Run -&gt; Edition Configurations menu item. In the Run\/Debug Configurations dialog, click [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[35,6,25,14],"_links":{"self":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/397"}],"collection":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=397"}],"version-history":[{"count":0,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/397\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=397"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}