lundi 22 avril 2019

Coverage is skipping return statements

I have a class and some tests for it. Coverage runs everything just fine, but reports that the lines containing return are not executed. The rest of the multi-line return statement is executed just fine, just not the return itself.

Class:

class Game(models.Model):
    ...

    def __str__(self):
    return (
        f'Name: {self.name}\n'
        f'Status: {self.status}\n'
    )

def render_html(self):
    return (
        f'Name: {escape(self.name)}<br/>'
        f'Status: {escape(self.status)}<br/>'
    )

The test is calling both render_html and __str__. I'm using Django and running with coverage run --branch ./manage.py test

Aucun commentaire:

Enregistrer un commentaire