Open Bug 1480337 Opened 3 years ago Updated 1 year ago

[wdspec] Use a fixture for shared basic transport commands

Categories

(Testing :: geckodriver, defect, P3)

Version 3
defect

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

The tests for all the commands specified by the WebDriver spec make use of shared methods inside their folders. To not have to duplicate those methods across all test files, move them into the __init__.py file.

https://searchfox.org/mozilla-central/source/testing/web-platform/tests/webdriver/tests
Comment on attachment 8997431 [details]
Bug 1480337 - [wdspec] Move shared methods into __init__.py file for each command.

https://reviewboard.mozilla.org/r/261204/#review268268

There’s a lot of test failures because the HTTP request functions
carry the same name as the module they’re in.  If you can solve
that, this looks OK.
Attachment #8997431 - Flags: review?(ato) → review+
The underlying problem here is actually not that the shared methods have the same name as the module, but that the fixtures don't care about the imported method, but try to make use of the global module. I assume that this happens because of the way how those are executed by pytest. Also it could mean that this is a bug in pytest. I will investigate and file a new issue against pytest if necessary.
Also please note that I'm not able to see those failures locally when I run the tests with `mach`. So maybe there is a different version of pytest in use, which might mean a new regression or a fix in one of the latest releases.

Currently I'm not working on this bug.

Assignee: hskupin → nobody
Status: ASSIGNED → NEW
Priority: P2 → P3

While working on bug 1650132 I found the solution for this problem. The shared basic transport helper can become a fixture:

@pytest.fixture(name="back")
def fixture_back(session):
    def inner():
        return session.transport.send(
            "POST", "session/{session_id}/back".format(**vars(session)))

    inner.__name__ = "back"
    return inner

With the above code it works perfectly.

Depends on: 1650132
Summary: [wdspec] Move shared methods into __init__.py file of appropriate command → [wdspec] Use a fixture for shared basic transport commands
You need to log in before you can comment on or make changes to this bug.