Exemple #1
0
    def test_toggle_cprofile_profiles(self):
        def my_method():
            return 1

        toggle_cprofile("my-process")
        my_method()
        toggle_cprofile("my-process")
        prof_path = self._get_prof_path("my-process")
        output = io.StringIO()
        stats = pstats.Stats(str(prof_path), stream=output)
        stats.print_callers()
        self.assertIn("my_method", output.getvalue())
Exemple #2
0
 def test_toggle_cprofile_writes_file(self):
     toggle_cprofile("my-process")
     toggle_cprofile("my-process")
     self.assertTrue(self._get_prof_path("my-process").exists())