Mercurial > hg
annotate tests/mockmakedate.py @ 45988:c6da62004c0f
tests: update test-chg.t with output change
Since this part of tests is only run with chg, hence it didn't get updated
when the error message changed.
Differential Revision: https://phab.mercurial-scm.org/D9414
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 27 Nov 2020 21:32:42 +0530 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
1 # mock out util.makedate() to supply testable values |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
2 |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
3 from __future__ import absolute_import |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
4 |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
5 import os |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
6 |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
7 from mercurial import pycompat |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
8 from mercurial.utils import dateutil |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
9 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41213
diff
changeset
|
10 |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
11 def mockmakedate(): |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
12 filename = os.path.join(os.environ['TESTTMP'], 'testtime') |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
13 try: |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
14 with open(filename, 'rb') as timef: |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
15 time = float(timef.read()) + 1 |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
16 except IOError: |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
17 time = 0.0 |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
18 with open(filename, 'wb') as timef: |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
19 timef.write(pycompat.bytestr(time)) |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
20 return (time, 0) |
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
21 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41213
diff
changeset
|
22 |
41213
704a3aa3dc0a
histedit: add rewrite.update-timestamp support to fold and mess
Taapas Agrawal <taapas2897@gmail.com>
parents:
diff
changeset
|
23 dateutil.makedate = mockmakedate |