Skip to content

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.

@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
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 <7629022+dongfangtianyu@users.noreply.github.com>
@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 <bruno@soliv.dev>
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 <bruno@soliv.dev>
(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 <bruno@soliv.dev>
(cherry picked from commit 28e1e25)

Co-authored-by: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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