coveragepy / coveragepy/django_coverage_plugin

Random error

Open
#22 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
202
Forks
38
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am facing a random error in my tests, with django 1.8.12, coverage 4.0.3 and django_coverage_plugin 1.3 (and seemingly only on my CI server using ubuntu precise 32bit, not our developer machines using ubuntu >= 14.04 64bit):

django_coverage_plugin/plugin.py", line 170, in line_number_range
    assert frame.f_code.co_name == 'render'
AssertionError

(Side note, as it is an AssertionError exception, the test reports it as a failure, not an error)

It seems to be called from django/template/engine.py, line 168 (https://github.com/django/django/blob/1.8.12/django/template/engine.py#L168):

    def get_template(self, template_name, dirs=_dirs_undefined):
        """
        Returns a compiled Template object for the given template name,
        handling template inheritance recursively.
        """
        # ... removed for brevity
        if not hasattr(template, 'render'):  # <<-- fails here
            # template needs to be compiled
            template = Template(template, origin, template_name, engine=self)

This call comes from a fairly standard return render_to_string(template_name, context.flatten()) in a template tag.

I've managed to get a shell at the point of failure, and frame.f_code.co_name is indeed 'get_template'.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at django_coverage_plugin/plugin.py line 170 and inspect the assertion in line_number_range, then compare it with the Django 1.8.12 path at django/template/engine.py line 168. Reproduce the failure on the Ubuntu Precise 32-bit CI environment using the render_to_string path; done means the assertion no longer fails and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.