GithubHelp home page GithubHelp logo

Comments (5)

coagulant avatar coagulant commented on May 19, 2024

I guess it's not too hard to make coveralls work with coverage 4.0b. However, adding newline to the end of python source file changes results a bit, compared to previous coverage version. Why is newline necessary?

from coveralls-python.

nedbat avatar nedbat commented on May 19, 2024

Thanks for looking into updating the support. 4.0 is not in beta yet, so the interfaces still are not finished, so it may be early to write code.

The newline is only necessary in some places (compiling to bytecode), and I could adjust how it is done, but can you tell me what kind of result changes you are seeing? I don't worry if the result numbers shift up or down a little bit.

from coveralls-python.

coagulant avatar coagulant commented on May 19, 2024

I'm using a custom reporter to get both coverage data and source file at the same time.
Here is a working report function, adapted to 4.0a2

def parse_file(self, cu, analysis):
        """ Generate data for single file """
        filename = cu.file_locator.relative_filename(cu.filename)
        coverage_lines = [self.get_hits(i, analysis) for i in range(1, len(cu.parser.lines) + 1)]
        source = cu.source()

        self.source_files.append({
            'name': filename,
            'source': source,
            'coverage': coverage_lines
        })

As coverage.py adds an empty newline to the end of the file, I'm seeing this extra line in sources and in coverage output. It's a minor discrepancy, but still...

Example: running coverage example/runtests.py results (full pytest output)

Coverage 3.X:

hits per line: [None, None, None, 1, 1, None, None, 1, None, None, None, 1, 0]
number of source lines in project.py: 13
json-encoded source as string: u'# coding: utf-8\n\n\ndef hello():\n    print(\'world\')\n\n\nclass Foo(object):\n    """ Bar """\n\n\ndef baz():\n    print(\'this is not tested\')'

Coverage 4.0a2:

hits per line: [None, None, None, 1, 1, None, None, 1, None, None, None, 1, 0, None]
number of source lines in project.py: 14
json-encoded source as string: u'# coding: utf-8\n\n\ndef hello():\n    print(\'world\')\n\n\nclass Foo(object):\n    """ Bar """\n\n\ndef baz():\n    print(\'this is not tested\')\n'

I don't think that adding one extra newline changes coverage numbers much, just wanted to let you know.

from coveralls-python.

nedbat avatar nedbat commented on May 19, 2024

Thanks for the explanation.

from coveralls-python.

coagulant avatar coagulant commented on May 19, 2024

Closing this in favor of #81

from coveralls-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.