| |
405 |
|
| |
406 |
class TestProfPlugin(unittest.TestCase):
|
| |
407 |
def test_options(self):
|
| |
408 |
parser = OptionParser()
|
| |
409 |
conf = Config()
|
| |
410 |
plug = Profile()
|
| |
411 |
|
| |
412 |
plug.add_options(parser, {})
|
| |
413 |
opts = [ o._long_opts[0] for o in parser.option_list ]
|
| |
414 |
assert '--profile-sort' in opts
|
| |
415 |
assert '--profile-stats-file' in opts
|
| |
416 |
assert '--with-profile' in opts
|
| |
417 |
assert '--profile-restrict' in opts
|
| |
418 |
|
| |
419 |
def test_begin(self):
|
| |
420 |
plug = Profile()
|
| |
421 |
plug.pfile = tempfile.mkstemp()[1]
|
| |
422 |
plug.begin()
|
| |
423 |
assert plug.prof
|
| |
424 |
|
| |
425 |
def test_prepare_test(self):
|
| |
426 |
r = {}
|
| |
427 |
class dummy:
|
| |
428 |
def runcall(self, f, r):
|
| |
429 |
r[1] = f(), "wrapped"
|
| |
430 |
def func():
|
| |
431 |
return "func"
|
| |
432 |
|
| |
433 |
plug = Profile()
|
| |
434 |
plug.prof = dummy()
|
| |
435 |
result = plug.prepareTest(func)
|
| |
436 |
result(r)
|
| |
437 |
assert r[1] == ("func", "wrapped")
|