avocado
avocado copied to clipboard
Error in pre_tests: 'Subscript' object has no attribute 'id'
Describe the bug When running the unit tests of our plugin with most recent Avocado I get
Error running method "pre_tests" of plugin "fetchasset": 'Subscript' object has no attribute 'id'
Steps to reproduce The invocation line I use for our unit tests is:
+ avocado run --nrunner-max-parallel-tasks=4 selftests/test_cartesian_graph.py selftests/test_cmd_parser.py selftests/test_intertest_setup.py selftests/test_params_parser.py selftests/test_state_setup.py selftests/test_vm_network.py
Expected behavior The error above is harmless to the overall run but still should not be there.
Current behavior As described above:
$ avocado run --nrunner-max-parallel-tasks=4 selftests/test_cartesian_graph.py selftests/test_cmd_parser.py selftests/test_intertest_setup.py selftests/test_params_parser.py selftests/test_state_setup.py selftests/test_vm_network.py
Error running method "pre_tests" of plugin "fetchasset": 'Subscript' object has no attribute 'id'
then the tests would run (the error is in red in the beginning).
System information (please complete the following information): I highly suspect that this could be due to some API change in Avocado that is not backward compatible and thus not reflected in our Avocado I2N plugin. So any guidance on possible commits that have introduced these changes are welcome. I will then inspect and adapt out plugin if such adaptation is necessary and indeed the culprit. I am mainly reporting this as it happens with "pure" avocado run (above) but as various plugins are loaded early on this can still be third-party plugin problem cause by downstream breakage.
Additional information It might also be related to the configuration of LXC spawner that I am currently testing-by-using so if you have pointers I can look into might also have to adjust the PR.
@pevogam this looks a lot like what was addressed by ed9d3ddea8dc6bba68a860f24d3d5a8dc04d86b5. Can you verify that?
Another related commit is 57d3c8ecad0eba8b1958cddba99e4e4ef0d16c72 .
BTW, it doesn't look like it's caused by the LXC Spawner IMO.
Another related commit is 57d3c8e .
BTW, it doesn't look like it's caused by the LXC Spawner IMO.
Indeed, very good pointers, doing this miniature diff fixes it:
diff --git a/avocado/plugins/assets.py b/avocado/plugins/assets.py
index b9b7e3cc..4571636a 100644
--- a/avocado/plugins/assets.py
+++ b/avocado/plugins/assets.py
@@ -261,6 +261,7 @@ class FetchAssetJob(JobPreTests): # pylint: disable=R0903
candidates = []
for suite in job.test_suites:
for test in suite.tests:
+ continue
# nrunner/resolver based test should describe their requirements
# explicitly using docstring statements. But, they can still
# benefit from the parsing of "fetch_asset()" calls just like
which then brings to the question: Why was this behavior changed from https://github.com/avocado-framework/avocado/commit/ed9d3ddea8dc6bba68a860f24d3d5a8dc04d86b5 to https://github.com/avocado-framework/avocado/commit/57d3c8ecad0eba8b1958cddba99e4e4ef0d16c72? The commit message doesn't seem to explain this too much.
Quickly dumping the test.kind
in the above code shows that all python unit tests are avocado-instrumented
and dumping the candidates
shows
('selftests/test_state_setup.py', 'StateSetupTest', 'test_qcow2_format')
('selftests/test_state_setup.py', 'StateSetupTest', 'test_qcow2_dash')
('selftests/test_state_setup.py', 'StateSetupTest', 'test_qcow2_convert')
so I don't quite see what in this strings tuple would cause missing id
attribute error.
I will check if this still applies, and if it does, I'll attempt @pevogam suggestion for fixing it.
Seems like with some of the recent logging changes under review I could obtain a full traceback here which might be helfpul:
Error running method "pre_tests" of plugin "fetchasset": 'Subscript' object has no attribute 'id'
Reproduced traceback from: /usr/lib/python3.10/site-packages/avocado/core/extension_manager.py:224
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 279, in pre_tests
fetch_assets(*candidate, logger)
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 227, in fetch_assets
handler = FetchAssetHandler(test_file, klass, method)
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 67, in __init__
self.visit(self.tree)
File "/usr/lib64/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/usr/lib64/python3.10/ast.py", line 418, in generic_visit
self.visit(item)
File "/usr/lib64/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 143, in visit_ClassDef
self.generic_visit(node)
File "/usr/lib64/python3.10/ast.py", line 418, in generic_visit
self.visit(item)
File "/usr/lib64/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 158, in visit_FunctionDef
self.generic_visit(node)
File "/usr/lib64/python3.10/ast.py", line 418, in generic_visit
self.visit(item)
File "/usr/lib64/python3.10/ast.py", line 410, in visit
return visitor(node)
File "/usr/lib/python3.10/site-packages/avocado/plugins/assets.py", line 189, in visit_Assign
name = node.targets[0].id
AttributeError: 'Subscript' object has no attribute 'id'