Skip to content

With pytest8.2.0 or later, test cases under test/distributed/ execute will meet issue "object has no attribute 'runTest'. Did you mean: 'run_test'" #127517

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

Open
hongfeng2013 opened this issue May 30, 2024 · 2 comments
Labels
oncall: distributed Add this issue/PR to distributed oncall triage queue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@hongfeng2013
Copy link

hongfeng2013 commented May 30, 2024

🐛 Describe the bug

This information is from "docs.pytest.org"
In pytest 8.2.0: #12089: pytest now requires that unittest.TestCase subclasses can be instantiated freely using MyTestCase('runTest').

  1. With this pytest-8.2.1 version, when I execute: pytest -v test_c10d_nccl.py::NCCLTraceTest
    image

  2. With pytest-8.1.1 version, when I execute: pytest -v test_c10d_nccl.py::NCCLTraceTest
    image

The related source code, torch/testing/_internal/common_distributed.py:

def __init__(self, method_name: str = "runTest") -> None:
        super().__init__(method_name)
        fn = getattr(self, method_name)
        setattr(self, method_name, self.join_or_run(fn))

Versions

Any pytorch version

cc @mrshenli @pritamdamania87 @zhaojuanmao @satgera @gqchen @aazzolini @osalpekar @jiayisuse @H-Huang @kwen2501 @awgu @penguinwu @fegin @XilunWu @wanchaol @fduwjj @wz337 @tianyu-l @wconstab @yf225 @chauhang @d4l3k

@zou3519 zou3519 added the oncall: distributed Add this issue/PR to distributed oncall triage queue label May 30, 2024
@kwen2501
Copy link
Contributor

kwen2501 commented Jun 2, 2024

Hi thanks for reporting.
Do you mean that with the new pytest version, one cannot rely on dynamically setting attr, but would need to define an runTest method?

@kwen2501 kwen2501 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 2, 2024
@hongfeng2013
Copy link
Author

Hi,
Thank you for your attention to this issue.

This information is from the pytest change log, the link is: https://docs.pytest.org/en/8.2.x/changelog.html
pytest 8.2.0 (2024-04-27)
Breaking Changes
#12089: pytest now requires that unittest.TestCase subclasses can be instantiated freely using MyTestCase('runTest').

If the class doesn’t allow this, you may see an error during collection such as AttributeError: 'MyTestCase' object has no attribute 'runTest'.

Classes which do not override init, or do not access the test method in init using getattr or similar, are unaffected.

Classes which do should take care to not crash when "runTest" is given, as is shown in unittest.TestCases’s implementation. Alternatively, consider using setUp instead of init.

@fduwjj fduwjj linked a pull request Sep 16, 2024 that will close this issue
fduwjj added a commit that referenced this issue Sep 17, 2024
Temporary fix to the issue in #127517. 


[ghstack-poisoned]
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oncall: distributed Add this issue/PR to distributed oncall triage queue triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants