Convert mozinfo test to pytest format
Categories
(Testing :: Mozbase, defect, P3)
Tracking
(firefox108 fixed)
Tracking | Status | |
---|---|---|
firefox108 | --- | fixed |
People
(Reporter: ahal, Assigned: gbrown)
References
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Reporter | ||
Comment 1•6 years ago
|
||
Comment 2•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Comment 3•6 years ago
|
||
I'd like to work on this one.
(In reply to Andrew Halberstadt [:ahal] from comment #0)
This means:
- Use 'assert foo == bar' instead of self.assertEquals(foo, bar)
What about its counterpart self.assertNotEqual(foo, bar)
? Should I change it to assert foo!= bar
?
Reporter | ||
Comment 4•6 years ago
|
||
Great, thanks for your interest!
Yes exactly, you can use any arbitrary boolean clause in the assert
statement. So whatever the semantic meaning of the old function being used, we just need to make sure we do the same thing in the assert.
Reporter | ||
Updated•6 years ago
|
Comment 5•6 years ago
|
||
I could handle most of the assert<relational-operator>()
methods, save assertRaises()
.
In resource 1, pytest.raises
helper is discussed as a context manager. I'm considering to replace all occurrences of assertRaises()
method in mozilla-central/testing/mozbase/mozinfo/tests/test.py
file with pytest.raises
helper.
In this process, I'd like to understand what do the second and third arguments to the assertRaises()
method signify?
I suppose the second argument is a callable as per 2 isn't it?
Thank you!
Reporter | ||
Comment 6•6 years ago
|
||
Yes, you have it right. The second argument is a function (or other callable), and the 3rd and 4th are the arguments you would pass into that function (if any). So you would convert this:
self.assertRaises(ValueError, func, arg1, arg2=None)
into this:
with pytest.raises(ValueError):
func(arg1, arg2=None)
Comment 7•4 years ago
|
||
Pooja: I'm releasing this bug due to inactivity. If you are still interested in working on it, please work with ahal or myself.
Updated•2 years ago
|
Assignee | ||
Comment 8•2 years ago
|
||
Updated•2 years ago
|
Comment 10•2 years ago
|
||
bugherder |
Description
•