mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-24 07:01:59 +00:00
Fix the test failing due to timestamp localisation, fixes #4853
from https://borgbackup.readthedocs.io/en/stable/usage/general.html#date-and-time Unless otherwise noted, we display local date and time. Internally, we store and process date and time as UTC. OK, that does not directly say something about --timestamp, but as the cli is also part of the user interface (as output is), this might mean that maybe not the test needs fixing, but our processing of that option. But, the docs also say: --timestamp TIMESTAMP manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format). Alternatively, give a reference file/directory. So, using UTC there is a documented feature, although it is different from output using localtime. So, the test fix in this PR is correct according to the docs. \o/
This commit is contained in:
parent
154239cd89
commit
c209eff842
1 changed files with 6 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
|||
from binascii import unhexlify, b2a_base64
|
||||
from configparser import ConfigParser
|
||||
from datetime import datetime
|
||||
from datetime import timezone
|
||||
from datetime import timedelta
|
||||
from hashlib import sha256
|
||||
from io import BytesIO, StringIO
|
||||
|
@ -2552,6 +2553,7 @@ def test_recreate_recompress(self):
|
|||
assert sha256_before == sha256_after
|
||||
|
||||
def test_recreate_timestamp(self):
|
||||
local_timezone = datetime.now(timezone(timedelta(0))).astimezone().tzinfo
|
||||
self.create_test_files()
|
||||
self.cmd('init', '--encryption=repokey', self.repository_location)
|
||||
archive = self.repository_location + '::test0'
|
||||
|
@ -2559,8 +2561,10 @@ def test_recreate_timestamp(self):
|
|||
self.cmd('recreate', '--timestamp', "1970-01-02T00:00:00", '--comment',
|
||||
'test', archive)
|
||||
info = self.cmd('info', archive).splitlines()
|
||||
assert any([re.search(r'Time \(start\).+ 1970-01-02', item) for item in info])
|
||||
assert any([re.search(r'Time \(end\).+ 1970-01-02', item) for item in info])
|
||||
dtime = datetime(1970, 1, 2) + local_timezone.utcoffset(None)
|
||||
s_time = dtime.strftime("%Y-%m-%d")
|
||||
assert any([re.search(r'Time \(start\).+ %s' % s_time, item) for item in info])
|
||||
assert any([re.search(r'Time \(end\).+ %s' % s_time, item) for item in info])
|
||||
|
||||
def test_recreate_dry_run(self):
|
||||
self.create_regular_file('compressible', size=10000)
|
||||
|
|
Loading…
Reference in a new issue