8000 correctly test skips · postgrespro/pg_probackup@b7bd831 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7bd831

Browse files
committed
correctly test skips
1 parent b17669c commit b7bd831

16 files changed

+71
-64
lines changed

tests/archive.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_pgpro434_2(self):
8686

8787
if self.get_version(node) < self.version_to_num('9.6.0'):
8888
self.del_test_dir(module_name, fname)
89-
return unittest.skip(
89+
self.skipTest(
9090
'Skipped because pg_control_checkpoint() is not supported in PG 9.5')
9191

9292
self.init_pb(backup_dir)
@@ -717,7 +717,7 @@ def test_replica_archive(self):
717717

718718
if self.get_version(master) < self.version_to_num('9.6.0'):
719719
self.del_test_dir(module_name, fname)
720-
return unittest.skip(
720+
self.skipTest(
721721
'Skipped because backup from replica is not supported in PG 9.5')
722722

723723
self.init_pb(backup_dir)
@@ -848,7 +848,7 @@ def test_master_and_replica_parallel_archiving(self):
848848

849849
if self.get_version(master) < self.version_to_num('9.6.0'):
850850
self.del_test_dir(module_name, fname)
851-
return unittest.skip(
851+
self.skipTest(
852852
'Skipped because backup from replica is not supported in PG 9.5')
853853

854854
replica = self.make_simple_node(
@@ -929,7 +929,7 @@ def test_basic_master_and_replica_concurrent_archiving(self):
929929
make sure that archiving on both node is working.
930930
"""
931931
if self.pg_config_version < self.version_to_num('9.6.0'):
932-
return unittest.skip('You need PostgreSQL >= 9.6 for this test')
932+
self.skipTest('You need PostgreSQL >= 9.6 for this test')
933933

934934
fname = self.id().split('.')[3]
935935
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -943,7 +943,7 @@ def test_basic_master_and_replica_concurrent_archiving(self):
943943

944944
if self.get_version(master) < self.version_to_num('9.6.0'):
945945
self.del_test_dir(module_name, fname)
946-
return unittest.skip(
946+
self.skipTest(
947947
'Skipped because backup from replica is not supported in PG 9.5')
948948

949949
replica = self.make_simple_node(
@@ -1035,7 +1035,7 @@ def test_concurrent_archiving(self):
10351035
"""
10361036

10371037
if self.pg_config_version < self.version_to_num('11.0'):
1038-
return unittest.skip('You need PostgreSQL >= 11 for this test')
1038+
self.skipTest('You need PostgreSQL >= 11 for this test')
10391039

10401040
fname = self.id().split('.')[3]
10411041
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1196,7 +1196,7 @@ def test_archive_pg_receivexlog_compression_pg10(self):
11961196
self.add_instance(backup_dir, 'node', node)
11971197
node.slow_start()
11981198
if self.get_version(node) < self.version_to_num('10.0'):
1199-
return unittest.skip('You need PostgreSQL >= 10 for this test')
1199+
self.skipTest('You need PostgreSQL >= 10 for this test')
12001200
else:
12011201
pg_receivexlog_path = self.get_bin_path('pg_receivewal')
12021202

@@ -1278,7 +1278,7 @@ def test_archive_catalog(self):
12781278

12791279
if self.get_version(master) < self.version_to_num('9.6.0'):
12801280
self.del_test_dir(module_name, fname)
1281-
return unittest.skip(
1281+
self.skipTest(
12821282
'Skipped because backup from replica is not supported in PG 9.5')
12831283

12841284
self.init_pb(backup_dir)
@@ -1938,7 +1938,7 @@ def test_waldir_outside_pgdata_archiving(self):
19381938
check that archive-push works correct with symlinked waldir
19391939
"""
19401940
if self.pg_config_version < self.version_to_num('10.0'):
1941-
return unittest.skip(
1941+
self.skipTest(
19421942
'Skipped because waldir outside pgdata is supported since PG 10')
19431943

19441944
fname = self.id().split('.')[3]
@@ -2176,7 +2176,7 @@ def test_archive_pg_receivexlog_partial_handling(self):
21762176

21772177
if self.get_version(node) < self.version_to_num('9.6.0'):
21782178
self.del_test_dir(module_name, fname)
2179-
return unittest.skip(
2179+
self.skipTest(
21802180
'Skipped because backup from replica is not supported in PG 9.5')
21812181

21822182
self.init_pb(backup_dir)
@@ -2385,7 +2385,7 @@ def test_archive_get_batching_sanity(self):
23852385

23862386
if self.get_version(node) < self.version_to_num('9.6.0'):
23872387
self.del_test_dir(module_name, fname)
2388-
return unittest.skip(
2388+
self.skipTest(
23892389
'Skipped because backup from replica is not supported in PG 9.5')
23902390

23912391
self.init_pb(backup_dir)

tests/backup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ def test_basic_temp_slot_for_stream_backup(self):
14281428
pg_options={'max_wal_size': '40MB'})
14291429

14301430
if self.get_version(node) < self.version_to_num('10.0'):
1431-
return unittest.skip('You need PostgreSQL >= 10 for this test')
1431+
self.skipTest('You need PostgreSQL >= 10 for this test')
14321432

14331433
self.init_pb(backup_dir)
14341434
self.add_instance(backup_dir, 'node', node)
@@ -1500,7 +1500,7 @@ def test_backup_concurrent_drop_table(self):
15001500
def test_pg_11_adjusted_wal_segment_size(self):
15011501
""""""
15021502
if self.pg_config_version < self.version_to_num('11.0'):
1503-
return unittest.skip('You need PostgreSQL >= 11 for this test')
1503+
self.skipTest('You need PostgreSQL >= 11 for this test')
15041504

15051505
fname = self.id().split('.')[3]
15061506
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1743,7 +1743,7 @@ def test_drop_table(self):
17431743
def test_basic_missing_file_permissions(self):
17441744
""""""
17451745
if os.name == 'nt':
1746-
return unittest.skip('Skipped because it is POSIX only test')
1746+
self.skipTest('Skipped because it is POSIX only test')
17471747

17481748
fname = self.id().split('.')[3]
17491749
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1790,7 +1790,7 @@ def test_basic_missing_file_permissions(self):
17901790
def test_basic_missing_dir_permissions(self):
17911791
""""""
17921792
if os.name == 'nt':
1793-
return unittest.skip('Skipped because it is POSIX only test')
1793+
self.skipTest('Skipped because it is POSIX only test')
17941794

17951795
fname = self.id().split('.')[3]
17961796
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/catchup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_basic_ptrack_catchup(self):
190190
Test ptrack catchup
191191
"""
192192
if not self.ptrack:
193-
return unittest.skip('Skipped because ptrack support is disabled')
193+
self.skipTest('Skipped because ptrack support is disabled')
194194

195195
# preparation 1: source
196196
src_pg = self.make_simple_node(
@@ -336,7 +336,7 @@ def test_tli_ptrack_catchup(self):
336336
Test that we correctly follow timeline change with ptrack catchup
337337
"""
338338
if not self.ptrack:
339-
return unittest.skip('Skipped because ptrack support is disabled')
339+
self.skipTest('Skipped because ptrack support is disabled')
340340

341341
# preparation 1: source
342342
src_pg = self.make_simple_node(
@@ -475,7 +475,7 @@ def test_table_drop_with_ptrack(self):
475475
Test that dropped table in source will be dropped in ptrack catchup'ed instance too
476476
"""
477477
if not self.ptrack:
478-
return unittest.skip('Skipped because ptrack support is disabled')
478+
self.skipTest('Skipped because ptrack support is disabled')
479479

480480
# preparation 1: source
481481
src_pg = self.make_simple_node(
@@ -590,7 +590,7 @@ def test_tablefile_truncation_with_ptrack(self):
590590
Test that truncated table in source will be truncated in ptrack catchup'ed instance too
591591
"""
592592
if not self.ptrack:
593-
return unittest.skip('Skipped because ptrack support is disabled')
593+
self.skipTest('Skipped because ptrack support is disabled')
594594

595595
# preparation 1: source
596596
src_pg = self.make_simple_node(
@@ -655,7 +655,7 @@ def test_local_tablespace_without_mapping(self):
655655
Test that we detect absence of needed --tablespace-mapping option
656656
"""
657657
if self.remote:
658-
return unittest.skip('Skipped because this test tests local catchup error handling')
658+
self.skipTest('Skipped because this test tests local catchup error handling')
659659

660660
src_pg = self.make_simple_node(base_dir = os.path.join(module_name, self.fname, 'src'))
661661
src_pg.slow_start()
@@ -1035,7 +1035,7 @@ def test_unclean_ptrack_catchup(self):
10351035
Test that we correctly recover uncleanly shutdowned destination
10361036
"""
10371037
if not self.ptrack:
1038-
return unittest.skip('Skipped because ptrack support is disabled')
1038+
self.skipTest('Skipped because ptrack support is disabled')
10391039

10401040
# preparation 1: source
10411041
src_pg = self.make_simple_node(
@@ -1507,7 +1507,7 @@ def test_dry_run_catchup_ptrack(self):
15071507
Test dry-run option for catchup in incremental ptrack mode
15081508
"""
15091509
if not self.ptrack:
1510-
return unittest.skip('Skipped because ptrack support is disabled')
1510+
self.skipTest('Skipped because ptrack support is disabled')
15111511

15121512
# preparation 1: source
15131513
src_pg = self.make_simple_node(

tests/compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_backward_compatibility_ptrack(self):
366366
"""Description in jira issue PGPRO-434"""
367367

368368
if not self.ptrack:
369-
return unittest.skip('Skipped because ptrack support is disabled')
369+
self.skipTest('Skipped because ptrack support is disabled')
370370

371371
fname = self.id().split('.')[3]
372372
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_delete_increment_page(self):
189189
def test_delete_increment_ptrack(self):
190190
"""delete increment and all after him"""
191191
if not self.ptrack:
192-
return unittest.skip('Skipped because ptrack support is disabled')
192+
self.skipTest('Skipped because ptrack support is disabled')
193193

194194
fname = self.id().split('.')[3]
195195
node = self.make_simple_node(

tests/external.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ def test_external_dir_is_symlink(self):
15351535
but restored as directory
15361536
"""
15371537
if os.name == 'nt':
1538-
return unittest.skip('Skipped for Windows')
1538+
self.skipTest('Skipped for Windows')
15391539

15401540
fname = self.id().split('.')[3]
15411541
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1618,7 +1618,7 @@ def test_external_dir_contain_symlink_on_dir(self):
16181618
but restored as directory
16191619
"""
16201620
if os.name == 'nt':
1621-
return unittest.skip('Skipped for Windows')
1621+
self.skipTest('Skipped for Windows')
16221622

16231623
fname = self.id().split('.')[3]
16241624
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1703,7 +1703,7 @@ def test_external_dir_contain_symlink_on_file(self):
17031703
but restored as directory
17041704
"""
17051705
if os.name == 'nt':
1706-
return unittest.skip('Skipped for Windows')
1706+
self.skipTest('Skipped for Windows')
17071707

17081708
fname = self.id().split('.')[3]
17091709
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/false_positive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_pg_10_waldir(self):
114114
test group access for PG >= 11
115115
"""
116116
if self.pg_config_version < self.version_to_num('10.0'):
117-
return unittest.skip('You need PostgreSQL >= 10 for this test')
117+
self.skipTest('You need PostgreSQL >= 10 for this test')
118118

119119
fname = self.id().split('.')[3]
120120
wal_dir = os.path.join(

tests/helpers/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
__all__ = ['ptrack_helpers', 'cfs_helpers', 'expected_errors']
2-
#from . import *
2+
3+
import unittest
4+
5+
# python 2.7 compatibility
6+
if not hasattr(unittest.TestCase, "skipTest"):
7+
def skipTest(self, reason):
8+
raise unittest.SkipTest(reason)
9+
unittest.TestCase.skipTest = skipTest

tests/incr_restore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ def test_make_replica_via_incr_checksum_restore(self):
14941494

14951495
if self.get_version(master) < self.version_to_num('9.6.0'):
14961496
self.del_test_dir(module_name, fname)
1497-
return unittest.skip(
1497+
self.skipTest(
14981498
'Skipped because backup from replica is not supported in PG 9.5')
14991499

15001500
self.init_pb(backup_dir)
@@ -1567,7 +1567,7 @@ def test_make_replica_via_incr_lsn_restore(self):
15671567

15681568
if self.get_version(master) < self.version_to_num('9.6.0'):
15691569
self.del_test_dir(module_name, fname)
1570-
return unittest.skip(
1570+
self.skipTest(
15711571
'Skipped because backup from replica is not supported in PG 9.5')
15721572

15731573
self.init_pb(backup_dir)

tests/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def test_merge_ptrack_truncate(self):
796796
restore last page backup and check data correctness
797797
"""
798798
if not self.ptrack:
799-
return unittest.skip('Skipped because ptrack support is disabled')
799+
self.skipTest('Skipped because ptrack support is disabled')
800800

801801
fname = self.id().split('.')[3]
802802
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,5 @@ def test_help_6(self):
239239
help_out.read().decode("utf-8")
240240
)
241241
else:
242-
return unittest.skip(
242+
self.skipTest(
243243
'You need configure PostgreSQL with --enabled-nls option for this test')

tests/ptrack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class PtrackTest(ProbackupTest, unittest.TestCase):
1717
def setUp(self):
1818
if self.pg_config_version < self.version_to_num('11.0'):
19-
return unittest.skip('You need PostgreSQL >= 11 for this test')
19+
self.skipTest('You need PostgreSQL >= 11 for this test')
2020
self.fname = self.id().split('.')[3]
2121

2222
# @unittest.skip("skip")

0 commit comments

Comments
 (0)
0