Skip to content
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

Fix: pytest >=8.1.0 displays no diff for AssertionError with `--impor… #12716

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

dongfangtianyu
Copy link
Contributor

closes #12659

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Aug 15, 2024
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @dongfangtianyu!

Please take a look at the comments.

@nicoddemus nicoddemus added the backport 8.3.x apply to PRs at any point; backports the changes to the 8.3.x branch label Aug 16, 2024
@dongfangtianyu
Copy link
Contributor Author

Thanks @nicoddemus ,resubmitted according to the comments

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dongfangtianyu!

@nicoddemus nicoddemus merged commit 9a444d1 into pytest-dev:main Aug 30, 2024
29 checks passed
Copy link

patchback bot commented Aug 30, 2024

Backport to 8.3.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.3.x/9a444d113658be6ccb8dc9f57ed118a1ef17c94c/pr-12716

Backported as #12755

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Aug 30, 2024
nicoddemus pushed a commit that referenced this pull request Aug 30, 2024
Fixes #12659

(cherry picked from commit 9a444d1)

Co-authored-by: dongfangtianyu <[email protected]>
@dongfangtianyu dongfangtianyu deleted the bugfix-12659 branch September 9, 2024 09:29
nicoddemus added a commit that referenced this pull request Dec 12, 2024
Regression in #12716  

In short: `PathFinder.find_spec` received the argument `/cow/moo` but loaded `/cow/moo/moo.py` instead.  

**Trigger conditions:**  
1. `/cow/moo/moo.py` exists (a file and directory with the same name).  
2. `/cow/moo/test_moo.py` exists (test case resides in the directory).  

When pytest loads test files in `importlib` mode, it continues recursive loading upward:  
- When loading `cow.moo`, it should return a namespace but unexpectedly returns a module.  
- When loading `cow.moo.moo`, it should return a module but unexpectedly returns a namespace.  

**Complete example:** [[GitHub repository](https://github.com/dongfangtianyu/pytest_importlib_issue)](https://github.com/dongfangtianyu/pytest_importlib_issue)  
- `main.py`: Reproduces the error.  
- `debug.py`: Demonstrates the behavior of `PathFinder.find_spec`.  

**Context:**
#12592 (comment)
#12592 (comment)


---------

Co-authored-by: Bruno Oliveira <[email protected]>
patchback bot pushed a commit that referenced this pull request Dec 12, 2024
Regression in #12716

In short: `PathFinder.find_spec` received the argument `/cow/moo` but loaded `/cow/moo/moo.py` instead.

**Trigger conditions:**
1. `/cow/moo/moo.py` exists (a file and directory with the same name).
2. `/cow/moo/test_moo.py` exists (test case resides in the directory).

When pytest loads test files in `importlib` mode, it continues recursive loading upward:
- When loading `cow.moo`, it should return a namespace but unexpectedly returns a module.
- When loading `cow.moo.moo`, it should return a module but unexpectedly returns a namespace.

**Complete example:** [[GitHub repository](https://github.com/dongfangtianyu/pytest_importlib_issue)](https://github.com/dongfangtianyu/pytest_importlib_issue)
- `main.py`: Reproduces the error.
- `debug.py`: Demonstrates the behavior of `PathFinder.find_spec`.

**Context:**
#12592 (comment)
#12592 (comment)

---------

Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit 28e1e25)
nicoddemus pushed a commit that referenced this pull request Dec 12, 2024
…#13054)

Regression in #12716

In short: `PathFinder.find_spec` received the argument `/cow/moo` but loaded `/cow/moo/moo.py` instead.

**Trigger conditions:**
1. `/cow/moo/moo.py` exists (a file and directory with the same name).
2. `/cow/moo/test_moo.py` exists (test case resides in the directory).

When pytest loads test files in `importlib` mode, it continues recursive loading upward:
- When loading `cow.moo`, it should return a namespace but unexpectedly returns a module.
- When loading `cow.moo.moo`, it should return a module but unexpectedly returns a namespace.

**Complete example:** [[GitHub repository](https://github.com/dongfangtianyu/pytest_importlib_issue)](https://github.com/dongfangtianyu/pytest_importlib_issue)
- `main.py`: Reproduces the error.
- `debug.py`: Demonstrates the behavior of `PathFinder.find_spec`.

**Context:**
#12592 (comment)
#12592 (comment)

---------

Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit 28e1e25)

Co-authored-by: dongfangtianyu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.3.x apply to PRs at any point; backports the changes to the 8.3.x branch bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest >=8.1.1 displays no diff for AssertionError with --import-mode=importlib
2 participants