tests/mocktime.py
author Sandu Turcan <idlsoft@gmail.com>
Tue, 03 May 2022 21:44:30 -0400
branchstable
changeset 49241 6b10151b9621
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
narrow_widen_acl: enforce narrowacl in narrow_widen (SEC) Reviewer note: this was sent by the author as a simple bugfix, but can be considered a security patch, since it allows users to access things outside of the ACL, hence the (SEC) prefix. However, this affects the `narrow` extention which is still marked as experimental and has relatively few users aside from large companies with their own security layers on top from what we can gather. We feel (Alphare: or at least, I feel) like pinging the packaging list is enough in this case.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34316
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
from __future__ import absolute_import
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
import os
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
import time
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 34316
diff changeset
     6
34316
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
class mocktime(object):
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
    def __init__(self, increment):
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
        self.time = 0
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
        self.increment = [float(s) for s in increment.split()]
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
        self.pos = 0
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
    def __call__(self):
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
        self.time += self.increment[self.pos % len(self.increment)]
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    15
        self.pos += 1
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    16
        return self.time
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 34316
diff changeset
    18
34316
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
def uisetup(ui):
12b355964de8 test-patchbomb: use mocktime
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
    time.time = mocktime(os.environ.get('MOCKTIME', '0.1'))