Closed Bug 1417554 Opened 7 years ago Closed 7 years ago

Convert moznetwork test to pytest format

Categories

(Testing :: Mozbase, enhancement)

enhancement
Not set
normal

Tracking

(firefox59 fixed)

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: ahal, Assigned: davehunt)

References

Details

Attachments

(3 files)

See bug 1397417 for the tracking bug with motivations for this change.

Here is the pytest documentation:
https://docs.pytest.org/en/latest/contents.html

That is a lot of information, but this bug is basically about modifying 'testing/mozbase/moznetwork/tests/test.py' to make better use of pytest (it is already running under pytest, but is structured as a unittest test).

This means:

1. Use 'assert foo == bar' instead of self.assertEquals(foo, bar)
2. Use module level test functions instead of unittest.TestCase based classes
3. Convert the 'verify_ip_in_list' function to a fixture which returns a function. More information on how fixtures work can be found here:
https://docs.pytest.org/en/latest/fixture.html

Changes can be tested with:
./mach python-test testing/mozbase/moznetwork

Or on try with:
./mach try fuzzy -q "'mozbase"

(or leave off the -q to choose it in the selection interface)
And of course, you'll need to test the lints as well:
./mach lint testing/mozbase/moznetwork
Assignee: nobody → dave.hunt
Status: NEW → ASSIGNED
Comment on attachment 8928952 [details]
Bug 1417554 - Use plain assert statements.

https://reviewboard.mozilla.org/r/200292/#review206436
Attachment #8928952 - Flags: review?(ahalberstadt) → review+
Comment on attachment 8928953 [details]
Bug 1417554 - Use module level test functions instead of unittest.TestCase classes.

https://reviewboard.mozilla.org/r/200294/#review206438
Attachment #8928953 - Flags: review?(ahalberstadt) → review+
Comment on attachment 8928954 [details]
Bug 1417554 - Use a session scoped fixture for obtaining the host IP addresses.

https://reviewboard.mozilla.org/r/200296/#review206440

Thanks Dave!
Attachment #8928954 - Flags: review?(ahalberstadt) → review+
Pushed by dhunt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/327cf77dc7b4
Use plain assert statements. r=ahal
https://hg.mozilla.org/integration/autoland/rev/3b9b4134fbe8
Use module level test functions instead of unittest.TestCase classes. r=ahal
https://hg.mozilla.org/integration/autoland/rev/017c3d88e600
Use a session scoped fixture for obtaining the host IP addresses. r=ahal
https://hg.mozilla.org/mozilla-central/rev/327cf77dc7b4
https://hg.mozilla.org/mozilla-central/rev/3b9b4134fbe8
https://hg.mozilla.org/mozilla-central/rev/017c3d88e600
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: