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

AttributeError: 'ElementTree' object has no attribute 'getiterator' when using --cocotbxml=... with Python 3.9.1 #130

Closed
amal-khailtash opened this issue Mar 5, 2021 · 7 comments

Comments

@amal-khailtash
Copy link

amal-khailtash commented Mar 5, 2021

With Python 3.9.1 I get the following error without

Traceback (most recent call last):
  ...
  File ".../cocotb_test/plugin.py", line 40, in pytest_sessionfinish
    for testsuite in tree.getiterator("testsuite"):
AttributeError: 'ElementTree' object has no attribute 'getiterator'

Based on the following bugfix:

  • What’s New In Python 3.9
    Methods getchildren() and getiterator() of classes ElementTree and Element in the ElementTree module have been removed. They were deprecated in Python 3.2. Use iter(x) or list(x) instead of x.getchildren() and x.iter() or list(x.iter()) instead of x.getiterator(). (Contributed by Serhiy Storchaka in bpo-36543.)
    • bpo-36543 Removed methods Element.getchildren(), Element.getiterator() and ElementTree.getiterator() and the xml.etree.cElementTree module.

Element.getiterator() should be replaced with .iter(x). Changing these two lines in cocotb_test/plugin.py:

40:                for testsuite in tree.getiterator("testsuite"):
...
44:                     for testcase in testsuite.getiterator("testcase"):

to:

40:                for testsuite in tree.iter("testsuite"):
...
44:                     for testcase in testsuite.iter("testcase"):

fixes the issue.

@themperek themperek added the bug Something isn't working label Mar 5, 2021
@themperek
Copy link
Owner

This is already there:

for testsuite in tree.iter("testsuite"):
use_element = None
for testcase in testsuite.iter("testcase"):

I can make the last release for cocotb 1.4

@themperek themperek removed the bug Something isn't working label Mar 5, 2021
@themperek
Copy link
Owner

I am closing this but feel free to reopen if needed.

@amal-khailtash
Copy link
Author

Yes, you are right, I think I encountered this with coco-tb 1.4. Thanks.

@amal-khailtash
Copy link
Author

I get this message though when I try to install cocotb-test. Is cocotb-test compatible with cocotb>=1.4? You seem to have a hard requirement on cocotb==1.4.

cocotb-test 0.1.2.dev0 requires cocotb==1.4.*, but you have cocotb 1.5.0rc2 which is incompatible.

And cocotb-bus 0.1.1 seems to requires cocotb<2.0,>=1.5.0.dev, so it only gets cocotb=1.4.0 and not cocotb=1.5.0rc2. Is it possible to relax cocotb-test requirement to be cocotb>=1.4?

@themperek
Copy link
Owner

Unfortunately, there are some incompatibilities so I did this to avoid issues.
This need to get in #128 for 1.5 support.

All this will get cleaned next week when cocotb 1.5 is released. Sorry for the inconvinicen.
I will also release new versions to the cocotb-test next week.

@amal-khailtash
Copy link
Author

That is alright, thanks for the info and this package. 😄

@amal-khailtash
Copy link
Author

amal-khailtash commented Mar 12, 2021

I confirm that the latest master branch works with cocotb 1.5 and modified pytest-parallel. Waiting for a new release of cocotb-test that depends on cocotb==1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants