Skip to content

Commit 161f64c

Browse files
committed
[PGPRO-5673] adapt tests/restore.py to Python-3.5 (used in travis tests)
1 parent ce33c9d commit 161f64c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ env:
5555
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE MODE=checkdb
5656
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE MODE=checkdb
5757
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE MODE=checkdb
58-
# - PG_VERSION=14 PG_BRANCH=REL_14_STABLE MODE=restore
59-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE MODE=restore
60-
# - PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=restore
61-
# - PG_VERSION=11 PG_BRANCH=REL_11_STABLE MODE=restore
62-
# - PG_VERSION=10 PG_BRANCH=REL_10_STABLE MODE=restore
63-
# - PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE MODE=restore
64-
# - PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE MODE=restore
58+
- PG_VERSION=14 PG_BRANCH=REL_14_STABLE MODE=restore
59+
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE MODE=restore
60+
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=restore
61+
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE MODE=restore
62+
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE MODE=restore
63+
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE MODE=restore
64+
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE MODE=restore
6565
# - PG_VERSION=14 PG_BRANCH=REL_14_STABLE MODE=ptrack
6666
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE MODE=ptrack
6767
# - PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=ptrack

tests/restore.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import subprocess
55
import sys
66
from time import sleep
7-
from datetime import datetime, timedelta
7+
from datetime import datetime, timedelta, timezone
88
import hashlib
99
import shutil
1010
import json
@@ -2140,7 +2140,8 @@ def test_restore_target_new_options(self):
21402140

21412141
target_name = 'savepoint'
21422142

2143-
target_time = datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S %z")
2143+
# in python-3.6+ it can be ...now()..astimezone()...
2144+
target_time = datetime.utcnow().replace(tzinfo=timezone.utc).astimezone().strftime("%Y-%m-%d %H:%M:%S %z")
21442145
with node.connect("postgres") as con:
21452146
res = con.execute(
21462147
"INSERT INTO tbl0005 VALUES ('inserted') RETURNING (xmin)")
@@ -2509,7 +2510,7 @@ def test_partial_restore_exclude(self):
25092510

25102511
db_list = {}
25112512
for line in db_list_splitted:
2512-
line = json.loads(line)
2513+
line = json.loads(line.decode('utf-8'))
25132514
db_list[line['datname']] = line['oid']
25142515

25152516
# FULL backup
@@ -2640,7 +2641,7 @@ def test_partial_restore_exclude_tablespace(self):
26402641

26412642
db_list = {}
26422643
for line in db_list_splitted:
2643-
line = json.loads(line)
2644+
line = json.loads(line.decode('utf-8'))
26442645
db_list[line['datname']] = line['oid']
26452646

26462647
# FULL backup

0 commit comments

Comments
 (0)