Ejemplo n.º 1
0
    def test_options(self):
        parser = OptionParser()
        conf = Config()
        plug = Profile()

        plug.add_options(parser, {})
        opts = [ o._long_opts[0] for o in parser.option_list ]
        assert '--profile-sort' in opts
        assert '--profile-stats-file' in opts
        assert '--with-profile' in opts
        assert '--profile-restrict' in opts
    def test_options(self):
        parser = OptionParser()
        conf = Config()
        plug = Profile()

        plug.add_options(parser, {})
        opts = [o._long_opts[0] for o in parser.option_list]
        assert '--profile-sort' in opts
        assert '--profile-stats-file' in opts
        assert '--with-profile' in opts
        assert '--profile-restrict' in opts
Ejemplo n.º 3
0
    def test_prepare_test(self):
        r = {}
        class dummy:
            def runcall(self, f, r):
                r[1] = f(), "wrapped"
        def func():
            return "func"

        plug = Profile()
        plug.prof = dummy()
        result = plug.prepareTest(func)
        try:
            result(r)
            assert r[1] == ("func", "wrapped")
        finally:
            plug.finalize(None)
 def test_begin(self):
     plug = Profile()
     plug.pfile = tempfile.mkstemp()[1]
     try:
         plug.begin()
         assert plug.prof
     finally:
         plug.finalize(None)
    def test_finalize(self):
        def func():
            pass

        plug = Profile()
        plug.begin()
        plug.prepareTest(func)
        pfile = plug.pfile
        try:
            assert os.path.exists(pfile)
        finally:
            plug.finalize(None)
        assert not os.path.exists(pfile), \
               "finalize did not remove temp file %s" % pfile
Ejemplo n.º 6
0
 def test_begin(self):
     plug = Profile()
     plug.pfile = tempfile.mkstemp()[1]
     try:
         plug.begin()
         assert plug.prof
     finally:
         plug.finalize(None)
Ejemplo n.º 7
0
 def test_pickle_configured(self):
     if 'java' in sys.version.lower():
         raise SkipTest("jython has no profiler plugin")
     c = nose.config.Config(plugins=DefaultPluginManager())
     config_args = ['--with-doctest', '--with-coverage', 
                  '--with-id', '--attr=A', '--collect', '--all',
                  '--with-isolation', '-d', '--with-xunit', '--processes=2',
                  '--pdb']
     if Profile.available():
         config_args.append('--with-profile')
     c.configure(config_args)
     cp = pickle.dumps(c)
     cc = pickle.loads(cp)
     assert cc.plugins._plugins
Ejemplo n.º 8
0
    def test_finalize(self):
        def func():
            pass

        plug = Profile()
        plug.begin()
        plug.prepareTest(func)
        pfile = plug.pfile
        try:
            assert os.path.exists(pfile)
        finally:
            plug.finalize(None)
        assert not os.path.exists(pfile), "finalize did not remove temp file %s" % pfile
Ejemplo n.º 9
0
 def test_pickle_configured(self):
     if 'java' in sys.version.lower():
         raise SkipTest("jython has no profiler plugin")
     c = nose.config.Config(plugins=DefaultPluginManager())
     config_args = [
         '--with-doctest', '--with-coverage', '--with-id', '--attr=A',
         '--collect', '--all', '--with-isolation', '-d', '--with-xunit',
         '--processes=2', '--pdb'
     ]
     if Profile.available():
         config_args.append('--with-profile')
     c.configure(config_args)
     cp = pickle.dumps(c)
     cc = pickle.loads(cp)
     assert cc.plugins._plugins
    def test_prepare_test(self):
        r = {}

        class dummy:
            def runcall(self, f, r):
                r[1] = f(), "wrapped"

        def func():
            return "func"

        plug = Profile()
        plug.prof = dummy()
        result = plug.prepareTest(func)
        try:
            result(r)
            assert r[1] == ("func", "wrapped")
        finally:
            plug.finalize(None)
Ejemplo n.º 11
0
 def setUp(self):
     if not Profile.available():
         raise SkipTest('profile plugin not available; skipping')
 def setUp(self):
     if not Profile.available():
         raise SkipTest('profile plugin not available; skipping')