-
-
Notifications
You must be signed in to change notification settings - Fork 448
Coverage misses with Python 3.10 #1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks, this is reported against CPython here: https://bugs.python.org/issue44616 |
Indeed, thanks @nedbat - that looks exactly like my case. |
The latest 3.10 head fixes this. Thanks! |
bpo 44616 is now fixed in the next 3.10 release. |
@nedbat Is this actually fully resolved? I have just updated a project to Python 3.10(.8) using coverage through pytest-cov (4.0.0 using coverage 6.5.0) with no logic changes and suddenly get very weird coverage results with what looks like - to me - impossible misses. Such as: If it is of note this code runs through the Apache beam SDK 2.43.0. |
@DerRidda Do you have a way for me to reproduce these failures? |
I will try to extract an minimal example for this behavior. |
Hi @nedbat, I'm encountering a similar issue where trivial lines are being marked as missing in the coverage report. However, when I add print statements for debugging, those lines are clearly being executed as they appear in the console output. I'm attaching screenshots below to illustrate the difference — one from Python 3.9 and the other from 3.10 — showing changes in coverage without any modifications to the source files. Python 3.10.16 and Code coverage for Python, version 7.8.0 with C extension: Python 3.9.20 and Code coverage for Python, version 7.2.3 with C extension: |
@Nik-09 double-check that you are combining and reporting the correct data files. Can you give me a way to reproduce the issue? |
Hi @nedbat , I confirm that I am combining and reporting the correct file. Regarding the reproduction steps: Here are the setup steps:
I understand these steps might be time-consuming, but I'm happy to try out any suggestions you have on my system. Thank you, |
@Nik-09 can you create a Dockerfile that does all of this? That would make it possible for us to have similar experiences. |
Hi Ned, I’ve created a Docker file for the project (pasted in the end). Please follow the steps below:
Observation: After running the test, search for the keyword The report shows line 524 is missing, which is a simple assignment operation "target_state_schema_version = feconf.CURRENT_STATE_SCHEMA_VERSION". But this line was covered in Python 3.9.20. Let me know if you have any questions. Thank you for your help. # Base image with required tools and Python build dependencies
FROM ubuntu:24.04
# Non-interactive install
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
git \
unzip \
openjdk-11-jre \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
llvm \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev \
direnv \
ca-certificates \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/*
# Install Chrome
RUN curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update && apt-get install -y google-chrome-stable
# Install pyenv
RUN curl https://pyenv.run | bash
# Set up pyenv environment variables
ENV PYENV_ROOT="/root/.pyenv"
ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
# Install Python 3.9.20 using pyenv
RUN bash -c "source ~/.bashrc && pyenv install 3.10.16 && pyenv global 3.10.16"
# Clone the Oppia repository from the custom branch
WORKDIR /root/opensource
RUN git clone -b python_migration https://github.com/Nik-09/oppia.git
WORKDIR /root/opensource/oppia
# Set up direnv hook
RUN echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
# Set up .direnvrc
RUN echo 'use_python() {\n\
local python_root=$(pyenv root)/versions/$1\n\
load_prefix "$python_root"\n\
if [[ -x "$python_root/bin/python" ]]; then\n\
layout python "$python_root/bin/python"\n\
else\n\
echo "Error: $python_root/bin/python cannot be executed."\n\
exit\n\
fi\n\
}' > ~/.direnvrc
# Set up .envrc to activate Python 3.9.20 environment
RUN echo 'use python 3.10.16' > ../.envrc
# Allow direnv
RUN direnv allow ..
# Install Python dependencies
# RUN pip install pyyaml setuptools coverage configparser
# Pre-download third-party libraries (simulate initial setup)
RUN bash scripts/install_prerequisites.sh || true
|
Describe the bug
I think there are still Python 3.10 compatibility problems, despite #1184 and #1106 and possibly other bugs. When testing flufl.lock against Python 3.10 (in CI and locally), I'm seeing line misses only in Python 3.10. These misses still appear to exist after testing locally with CPython 3.10 head and coveragepy head.
To Reproduce
git clone https://gitlab.com/warsaw/flufl.lock.git
cd flufl.lock
git switch qa
tox -e py39 -e py310
Expected behavior (Python 3.9)
Actual behavior (Python 3.10)
From local testing the lines are covered AFAICT, so there should be no functional difference between 3.9 and 3.10. The commonality is that these are conditionals inside try/excepts with raises in the true branch of the conditional.
The text was updated successfully, but these errors were encountered: