Python timeit 模块,reindent() 实例源码

我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用timeit.reindent()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def __init__(self, stmt, setup='pass', timer=timeit.default_timer, globals=globals()):
        # copy of timeit.Timer.__init__
        # similarity index 95%
        self.timer = timer
        stmt = timeit.reindent(stmt, 8)
        setup = timeit.reindent(setup, 4)
        src = timeit.template % {'stmt': stmt, 'setup': setup}
        self.src = src  # Save for traceback display
        code = compile(src, timeit.dummy_src_name, "exec")
        ns = {}
        #exec code in globals(), ns      -- original timeit code
        exec_(code, globals, ns)  # -- we use caller-provided globals instead
        self.inner = ns["inner"]
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")
项目:Python-iBeacon-Scan    作者:NikNitro    | 项目源码 | 文件源码
def __init__(self, stmt, setup='pass', timer=timeit.default_timer, globals=globals()):
        # copy of timeit.Timer.__init__
        # similarity index 95%
        self.timer = timer
        stmt = timeit.reindent(stmt, 8)
        setup = timeit.reindent(setup, 4)
        src = timeit.template % {'stmt': stmt, 'setup': setup}
        self.src = src  # Save for traceback display
        code = compile(src, timeit.dummy_src_name, "exec")
        ns = {}
        #exec code in globals(), ns      -- original timeit code
        exec_(code, globals, ns)  # -- we use caller-provided globals instead
        self.inner = ns["inner"]
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_reindent_empty(self):
        self.assertEqual(timeit.reindent("", 0), "")
        self.assertEqual(timeit.reindent("", 4), "")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_reindent_single(self):
        self.assertEqual(timeit.reindent("pass", 0), "pass")
        self.assertEqual(timeit.reindent("pass", 4), "pass")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_reindent_multi_empty(self):
        self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
        self.assertEqual(timeit.reindent("\n\n", 4), "\n    \n    ")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_reindent_multi(self):
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 0),
            "print()\npass\nbreak")
        self.assertEqual(timeit.reindent(
            "print()\npass\nbreak", 4),
            "print()\n    pass\n    break")