Issue 1550272: Add a test suite for unittest (original) (raw)

Oh the irony. :)

This is good stuff. I have not reviewed the whole patch, but sampling bits of it it looks fine. No great danger in committing this, so why not let's commit it?

Of the following points, I think only the first should block commit of this patch. Any comments on that first point?

  1. test_loadTestsFromName__module_not_loaded() and test_loadTestsFromNames__module_not_loaded() -- these may break in future, and may break e.g. only when running tests in random order, which is sometimes done when debugging obscure stuff. Better to introduce a module of your own in Lib/test that's guaranteed not to be loaded already -- maybe test_unittest_fodder.py . Still, that wouldn't help the case where somebody is running the tests in a loop, which would cause failures already (again, this is something people do as part of bug detection / removal). I don't know the import internals and I hear they're messy, but perhaps just del sys.modules[module_name] at the start of each of those two methods is at least an improvement over what they do now.

  2. Would be helpful to list what remains to be tested (for example, there is no test of assertRaises)

  3. Why no use of .assertRaises?

  4. Would be nice to resolve some of the XXXes, but I realise that this may be difficult/impossible given the requirement for backwards-compatibility

Point 1: I vaguely remember having a reason for not doing 'del sys.modules[module_name]' back when I wrote the suite, but I can't think of what it is now. I've amended the suite to use that line.

Point 2: I've added a list at the top of things that have yet to be tested. The TestCase.assert* and TestCase.fail* methods still need explicit tests, though most are tested implicitly in the test suite itself.

Point 3: I think assertRaises is ugly : )

Point 4: I've given up on resolving a number of the XXXs in 2.x, though I'm working on a rewrite of unittest for 3.x that will resolve all such issues.

Thanks! File Added: test_unittest.py