Fixed mtultiple chained errors thrown when using pytest Tavern #367
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A framework exists above Pytest which is called Tavern. It is using YAML files to execute API tests. During the execution of the tests in this framework and due to the difference it has in the structure of the test suites in respect to BDD for example, some changes were needed as some exceptions were thrown and the integration of the pytest execution with Reportportal was not possible / blocked.
Points of failure
Original name attribute
The first point of failure is due to the fact that the Tavern framework do not use the
originalname
in the test item. This change fixes the issue with theoriginalname
checking if its existing in the item as an attribute.If the
originalname
attribute does not exist then instead of using theitem.name
defined in this if / else statement, it was throwing the following error:Parent attribute
In the line 467 a check for the parent attribute has been added. The reason of this is the item structure of the Tavern framework in comparison with the rest of the Pytest Item structure. After getting the first time the parent object in line 461, then the Tavern framework does not have at all parents set. (Although it depends somehow to the test implementation, but always after the root object, parent is NoneType).
Falling in this case the framework throws the following exception:
So in the line 467 we check if parent attribute exists so as to step into it otherwise breaks the loop. If the loop is not broken at this point it ends up having an infinite loop.
Parent name
In the line 464 we check if the attribute
name
exists in the parent. The reason of doing so is the fact that at a point the parent object is not related to the test (It may be Session object for example) and this was throwing a name does not exist error as follows: