Skip to content

Coverage reports line as uncovered when run. #1432

Closed as not planned
Closed as not planned
@jmgurney

Description

@jmgurney

Describe the bug

I have found that apparently coverage reports a continue statement as being uncovered even though it is run/executed.

To Reproduce

  1. Python 3.9.13 (main, May 30 2022, 11:25:38) (tested on Python 3.10.4 (main, May 23 2022, 16:05:39) and doesn't reproduce)
-- sys -------------------------------------------------------
               coverage_version: 6.4.2
                coverage_module: /private/tmp/cv/p/lib/python3.9/site-packages/coverage/__init__.py
                         tracer: -none-
                        CTracer: available
           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.9.13 (main, May 30 2022, 11:25:38) [Clang 13.0.0 (clang-1300.0.29.30)]
                       platform: macOS-12.4-x86_64-i386-64bit
                 implementation: CPython
                     executable: /private/tmp/cv/p/bin/python
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 29182
                            cwd: /private/tmp/cv
                           path: /private/tmp/cv
                                 /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
                                 /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9
                                 /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
                                 /private/tmp/cv/p/lib/python3.9/site-packages
                    environment: HOME = /Users/jmg
                   command_line: /private/tmp/cv/p/lib/python3.9/site-packages/coverage/__main__.py debug sys
                sqlite3_version: 2.6.0
         sqlite3_sqlite_version: 3.38.5
             sqlite3_temp_store: 0
        sqlite3_compile_options: ATOMIC_INTRINSICS=1, COMPILER=clang-13.0.0, DEFAULT_AUTOVACUUM,
                                 DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4,
                                 DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096,
                                 DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS,
                                 DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2,
                                 DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2,
                                 DEFAULT_WORKER_THREADS=0, DISABLE_INTRINSIC, ENABLE_COLUMN_METADATA,
                                 ENABLE_FTS3, ENABLE_FTS3_PARENTHESIS, ENABLE_FTS4, ENABLE_FTS5,
                                 ENABLE_GEOPOLY, ENABLE_MATH_FUNCTIONS, ENABLE_RTREE, ENABLE_STAT4,
                                 ENABLE_UNLOCK_NOTIFY, MALLOC_SOFT_LIMIT=1024, MAX_ATTACHED=10,
                                 MAX_COLUMN=2000, MAX_COMPOUND_SELECT=500, MAX_DEFAULT_PAGE_SIZE=8192,
                                 MAX_EXPR_DEPTH=1000, MAX_FUNCTION_ARG=127, MAX_LENGTH=1000000000,
                                 MAX_LIKE_PATTERN_LENGTH=50000, MAX_MMAP_SIZE=0x7fff0000,
                                 MAX_PAGE_COUNT=1073741823, MAX_PAGE_SIZE=65536, MAX_SQL_LENGTH=1000000000,
                                 MAX_TRIGGER_DEPTH=1000, MAX_VARIABLE_NUMBER=32766, MAX_VDBE_OP=250000000,
                                 MAX_WORKER_THREADS=8, MUTEX_PTHREADS, SECURE_DELETE, SOUNDEX,
                                 SYSTEM_MALLOC, TEMP_STORE=1, THREADSAFE=1
coverage==6.4.2
  1. What code shows the problem?
for i in ['a', 'b', 'c']:
	if i == 'a':
		print('d')
	elif i == 'b':
		print('e')
	elif i == 'c':
		print('f')
	else: # pragma: no cover
		raise ValueError('unhnadled')

	continue

	raise Exception('an exception')
  1. What commands did you run?
python -m coverage run t.py
python -m coverage report -m

Expected behavior

I expect that the report only shows that line 13 is uncovered, but line 11 should be covered as it is the continue that prevents line 13 from running.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions