Skip to content

Incomplete coverage reported with python 3.11.0-alpha.1 #1270

Closed
@jepler

Description

@jepler

A minimized test case shows a branch with only partial coverage when using python 3.11.0-alpha.0, but 100% coverage with a wide range of other python versions.

To Reproduce
How can we reproduce the problem? Please be specific. Don't just link to a failing CI job. Answer the questions below:

  1. python3.11 from https://github.com/actions/python-versions/releases/download/3.11.0-alpha.1-117932/python-3.11.0-alpha.1-linux-20.04-x64.tar.gz
  2.  $ coverage debug sys
     -- sys -------------------------------------------------------
                coverage_version: 6.1.1
                 coverage_module: /tmp/311env/lib/python3.11/site-packages/coverage/__init__.py
                          tracer: -none-
                         CTracer: unavailable
            plugins.file_tracers: -none-
             plugins.configurers: -none-
       plugins.context_switchers: -none-
               configs_attempted: .coveragerc
                                  setup.cfg
                                  tox.ini
                                  pyproject.toml
                    configs_read: -none-
                     config_file: None
                 config_contents: -none-
                       data_file: -none-
                          python: 3.11.0a1 (default, Oct 18 2021, 14:24:01) [GCC 9.3.0]
                        platform: Linux-5.10.0-8-amd64-x86_64-with-glibc2.31
                  implementation: CPython
                      executable: /tmp/311env/bin/python3
                    def_encoding: utf-8
                     fs_encoding: utf-8
                             pid: 2221646
                             cwd: /tmp/co
                            path: /tmp/311env/bin
                                  /tmp/py311/lib/python311.zip
                                  /tmp/py311/lib/python3.11
                                  /tmp/py311/lib/python3.11/lib-dynload
                                  /tmp/311env/lib/python3.11/site-packages
                     environment: HOME = /home/jepler
                    command_line: /tmp/311env/bin/coverage debug sys
                 sqlite3_version: 2.6.0
          sqlite3_sqlite_version: 3.34.1
              sqlite3_temp_store: 0
         sqlite3_compile_options: COMPILER=gcc-10.2.1 20210110; ENABLE_COLUMN_METADATA; ENABLE_DBSTAT_VTAB
                                  ENABLE_FTS3; ENABLE_FTS3_PARENTHESIS; ENABLE_FTS3_TOKENIZER
                                  ENABLE_FTS4; ENABLE_FTS5; ENABLE_JSON1
                                  ENABLE_LOAD_EXTENSION; ENABLE_PREUPDATE_HOOK; ENABLE_RTREE
                                  ENABLE_SESSION; ENABLE_STMTVTAB; ENABLE_UNLOCK_NOTIFY
                                  ENABLE_UPDATE_DELETE_LIMIT; HAVE_ISNAN; LIKE_DOESNT_MATCH_BLOBS
                                  MAX_SCHEMA_RETRY=25; MAX_VARIABLE_NUMBER=250000; OMIT_LOOKASIDE
                                  SECURE_DELETE; SOUNDEX; TEMP_STORE=1
                                  THREADSAFE=1; USE_URI
    

Code:

import unittest

class ExceptionCoverage(unittest.TestCase):
    def test_exception_coverage(self) -> None:
        with self.assertRaises(ZeroDivisionError):
            1/0

if __name__ == '__main__': # pragma no cover
    unittest.main()

Running:

$ python3 -mcoverage run --branch test_assertraises.py && python3 -mcoverage report --fail-under=100
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
Name                   Stmts   Miss Branch BrPart  Cover
--------------------------------------------------------
test_assertraises.py       5      0      2      1    86%
--------------------------------------------------------
TOTAL                      5      0      2      1    86%
Coverage failure: total of 86 is less than fail-under=100

Expected behavior
When running under Python 3.11-alpha.0, the same 100% branch coverage should be shown as under 3.9 and other Python versions

Additional context
This is a minimized version of a problem affecting https://github.com/jepler/wwvbpy. As with

this is probably a bug in the underlying Python implementation, but hopefully you are able to better engage with the python devs than I can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcpythonReported as a bug in CPythonfixed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions