GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sqlmap/tests/test_profiling.py at master · sqlmapproject/sqlmap Expand file tree/ Copy pathtest_profiling.pyMore file actions 59 lines (43 loc) · 1.78 KB / Copy pathtest_profiling.pyFile metadata and controls59 lines (43 loc) · 1.78 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 #!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Switch '--profile' (lib/core/profiling.py). The profiled statement must resolve 'start' from an explicit namespace: on pip installs __main__ is the console script, not sqlmap.py, so relying on it raised NameError (#6096). This test runs under a unittest __main__ that has no 'start' either, so it covers that case. """ import os import pstats import shutil import sys import tempfile import unittest sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from _testutils import bootstrap bootstrap() import lib.controller.controller as controller from lib.core.profiling import profile class TestProfiling(unittest.TestCase): def setUp(self): self._saved = controller.start self._dir = tempfile.mkdtemp() self._out = os.path.join(self._dir, "sqlmap_profile.raw") def tearDown(self): controller.start = self._saved shutil.rmtree(self._dir, ignore_errors=True) def test_profile_does_not_need_start_in_main(self): calls = [] controller.start = lambda *args, **kwargs: calls.append(True) profile(self._out) self.assertEqual(calls, [True], msg="start() was never run under the profiler") self.assertTrue(os.path.exists(self._out), msg="no raw profile written") self.assertTrue(pstats.Stats(self._out).stats, msg="raw profile holds no stats") def test_profile_overwrites_a_stale_output_file(self): controller.start = lambda *args, **kwargs: None with open(self._out, "wb") as f: f.write(b"not a pstats file") profile(self._out) self.assertTrue(pstats.Stats(self._out).stats) if __name__ == "__main__": unittest.main() |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |