pytest assertion rewriting does not seem to work with meson editable install
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- build-system, testing-qa
Hướng nghiên cứu
Bắt đầu với reproducer trong numpy/tests/test_mine.py và so sánh đầu ra của pytest sau các lệnh cài đặt normal và editable được ghi trong tài liệu. Theo dõi cách quá trình cài đặt editable ảnh hưởng đến việc viết lại assertion của pytest, sử dụng issue Meson được liên kết làm ngữ cảnh. Hoàn tất khi lần chạy với cài đặt editable báo cáo các giá trị assertion đã được đánh giá, khớp với hành vi khi cài đặt normal.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
It could well be partially linked to some of the discussion in https://github.com/mesonbuild/meson-python/issues/642 but I thought a separate issue may be worth it.
Description of the issue
The pytest assertion rewriting that shows additional debug information when an assert fails does not show up when using meson editable install. It does work fine when using normal (non-editable) meson install. Although not crucial I would argue that this can be actually quite useful in CI logs.
It could also well be a Pytest issue but I thought I had to start somewhere and chose meson-python.
More background about Pytest assertion rewriting, see Pytest doc that links to a somewhat old blog post but I am guessing is probably still relevant?
This was originally seen in scikit-learn (see https://github.com/scikit-learn/scikit-learn/issues/29253#issuecomment-2173549242 if you are really curious where it would have actually been quite useful to see intermediary values in the AssertionError in https://github.com/scikit-learn/scikit-learn/issues/29253#issuecomment-2167610891). I put together a reproducer below with numpy hoping this makes it a bit easier to look at. I guess a smaller reproducer could be put together if deemed useful, but it would take a bit of time (I tried with https://github.com/dnicolodi/python-siphash24 and I am not able to reproduce the issue).
Get the reproducer from my numpy branch
git clone https://github.com/lesteve/numpy
cd numpy
git checkout meson-editable-pytest-assertion-rewrite
I added a simple test in numpy/tests/test_mine.py
import numpy as np
def test():
arr = np.arange(100)
assert arr.sum() < 100
When running with pytest you pytest assertion rewriting shows the value or arr.sum() (see below).
Normal (non-editable) install
pip install --verbose --no-build-isolation .
Note the assertion rewriting i.e. you get the value of arr.sum()
Partial output:
E assert np.int64(4950) < 100
E + where np.int64(4950) = <built-in method sum of numpy.ndarray object at 0x7b77efd7a370>()
Full output
❯ pytest --pyargs numpy.tests.test_mine
========================== test session starts ===========================
platform linux -- Python 3.11.7, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/lesteve
plugins: hypothesis-6.103.2
collected 1 item
micromamba/envs/numpy-dev/lib/python3.11/site-packages/numpy/tests/test_mine.py F [100%]
================================ FAILURES ================================
__________________________________ test __________________________________
def test():
arr = np.arange(100)
> assert arr.sum() < 100
E assert np.int64(4950) < 100
E + where np.int64(4950) = <built-in method sum of numpy.ndarray object at 0x7b77efd7a370>()
E + where <built-in method sum of numpy.ndarray object at 0x7b77efd7a370> = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19, 20, 21, 22, 23, 24, 25, ...72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]).sum
micromamba/envs/numpy-dev/lib/python3.11/site-packages/numpy/tests/test_mine.py:6: AssertionError
======================== short test summary info =========================
FAILED micromamba/envs/numpy-dev/lib/python3.11/site-packages/numpy/tests/test_mine.py::test - assert np.int64(4950) < 100
=========================== 1 failed in 0.82s ============================
Editable install
pip install --verbose --no-build-isolation --editable . --config-settings editable-verbose=true
You don't get the value of arr.sum()
pytest --pyargs numpy.tests.test_mine
========================== test session starts ===========================
platform linux -- Python 3.11.7, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/lesteve
plugins: hypothesis-6.103.2
collecting ... + /home/lesteve/micromamba/envs/numpy-dev/bin/ninja
[1/1] Generating numpy/generate-version with a custom command
Saving version to numpy/version.py
collected 1 item
dev/numpy/numpy/tests/test_mine.py F [100%]
================================ FAILURES ================================
__________________________________ test __________________________________
def test():
arr = np.arange(100)
> assert arr.sum() < 100
E AssertionError
dev/numpy/numpy/tests/test_mine.py:6: AssertionError
======================== short test summary info =========================
FAILED dev/numpy/numpy/tests/test_mine.py::test - AssertionError
=========================== 1 failed in 1.02s ============================
- Ngôn ngữ chính
- Python
- Star
- 180
- Fork
- 93
- Merge trung bình
- 20 giờ 58 phút
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mesonbuild/meson-python
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
mesonbuild/meson-python#541 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
mesonbuild/meson-python#473 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation enhancement tests
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
mesonbuild/meson-python#903 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
mesonbuild/meson-python#871 · 7 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pip install overrides existing build configurationCó thể đã có người làm @Alvaro-Kothe đã nhận 115 ngày trước. Đang mởquestion
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
mesonbuild/meson-python#851 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của mesonbuild/meson-python
Issue tương tự
-
[Bug]: `graphify export svg` writes a graph.svg that is not well-formed XML when a label contains a control characterCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Graphify-Labs/graphify#4241 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
DeviceTrackerĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
XiaoMi/ha_xiaomi_home#1821 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Maven path-index: "Ambiguous or noncanonical artifact path" error does not report the offending pathĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
pulp/pulp_maven#524 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày