Skip to content

Can't get code coverage to work.... #1731

@alan412

Description

@alan412
  • I'm submitting a ...
  • bug report
  • feature request
  • question about the decisions made in the repository
  • Do you want to request a feature or report a bug?
    I don't know if it is a bug or just my not knowing what I am doing.

  • What is the current behavior?
    When I try to execute covercp.py, I get the following:

(venv3) Honeycrisp2018:CheckMeIn alan$ python venv3/lib/python3.6/site-packages/cherrypy/lib/covercp.py 
Traceback (most recent call last):
  File "venv3/lib/python3.6/site-packages/cherrypy/lib/covercp.py", line 391, in <module>
    serve(*tuple(sys.argv[1:]))
  File "venv3/lib/python3.6/site-packages/cherrypy/lib/covercp.py", line 377, in serve
    if coverage is None:
UnboundLocalError: local variable 'coverage' referenced before assignment

If I comment out lines 377 and 378 then it will start up, but I get the following on the left hand side:
500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/Users/alan/Projects/CheckMeIn/venv3/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 630, in respond
    self._do_respond(path_info)
  File "/Users/alan/Projects/CheckMeIn/venv3/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 689, in _do_respond
    response.body = self.handler()
  File "/Users/alan/Projects/CheckMeIn/venv3/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 264, in __call__
    ct.params['charset'] = self.find_acceptable_charset()
  File "/Users/alan/Projects/CheckMeIn/venv3/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 173, in find_acceptable_charset
    if encoder(self.default_encoding):
  File "/Users/alan/Projects/CheckMeIn/venv3/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 114, in encode_string
    for chunk in self.body:
  File "venv3/lib/python3.6/site-packages/cherrypy/lib/covercp.py", line 325, in menu
    tree = get_tree(base, exclude, self.coverage)
  File "venv3/lib/python3.6/site-packages/cherrypy/lib/covercp.py", line 280, in get_tree
    runs = coverage.data.executed_files()
AttributeError: 'CoverageData' object has no attribute 'executed_files'
  • What is the expected behavior?
    I would really like (and think would be great to have in the documentation) an example using code coverage of one of the tutorial projects. I suspect I am just doing something not very smart.

  • What is the motivation / use case for changing the behavior?
    I would like to use code coverage to make sure my tests are covering enough of the project for a release.

  • Please tell us about your environment:

  • CherryPy version: 17.3.0
    -Python 3.6.1
  • Python version: 3.6.X

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions