Closed Bug 779664 Opened 10 years ago Closed 10 years ago

moztest needs tests

Categories

(Testing :: Mozbase, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: k0scist, Assigned: mihneadb)

References

Details

Attachments

(1 file, 1 obsolete file)

oh the irony.  moztest needs some tests for its results and output
capabilities.  A good first round should mostly be tests illustrating
the API and smoke-testing it
QA Contact: mbalaur
Assignee: nobody → mbalaur
Attached patch some first tests + required mods (obsolete) — Splinter Review
I had to improve some of the code in results.py, thanks to the tests.
Attachment #648570 - Flags: feedback?(jhammel)
Blocks: 779665
Comment on attachment 648570 [details] [diff] [review]
some first tests + required mods

Its great to see tests!  You'll also need to make a manifest for it (see the other tests directories) and add this to the root test-manifest.ini.  Other than that, looks good.

+           self.hostname == other.hostname and
+           self.arch == other.arch and
+           self.env == other.env and
+           self.os == other.os and
+           self.os_version == other.os_version

I'd rather see a TestContext class variable, e.g. `keys` with these values and then a comparison e.g

isinstance(other, TestContext) and not [i for i in keys if getattr(self, i) == getattr(other, i)]

This way, one can add keys without having to change in multiple places.  I'm not sure how to fix hash exactly, but maybe

attrs = [getattr(self, i) for i in self.keys]
return hash(tuple([(isinstance(i, dict) and tuple(i.items()) or i) for i in attrs]))

Not wonderful, but I'm not sure if there is a standard way to hash standard mutable types in python, though if we need it it can be done

+        self.assertTrue(math.fabs(duration - t.duration) < 1)

Good enough, I guess.
Attachment #648570 - Flags: feedback?(jhammel) → feedback+
sorry, meant:

not [i for i in keys if getattr(self, i) != getattr(other, i)]

Oh boolean logic!
Attachment #648570 - Attachment is obsolete: true
Attachment #648790 - Flags: review?(jhammel)
Comment on attachment 648790 [details] [diff] [review]
fix according to feedback

Looks good to me!
Attachment #648790 - Flags: review?(jhammel) → review+
You need to log in before you can comment on or make changes to this bug.