8000 Using pytest [assertIn] · postgrespro/testgres@4afbe00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4afbe00

Browse files
Using pytest [assertIn]
1 parent eaaa276 commit 4afbe00

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

tests/test_simple.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ def test_safe_psql__expect_error(self):
321321
with get_new_node().init().start() as node:
322322
err = node.safe_psql('select_or_not_select 1', expect_error=True)
323323
assert (type(err) == str) # noqa: E721
324-
self.assertIn('select_or_not_select', err)
325-
self.assertIn('ERROR: syntax error at or near "select_or_not_select"', err)
324+
assert ('select_or_not_select' in err)
325+
assert ('ERROR: syntax error at or near "select_or_not_select"' in err)
326326

327327
# ---------
328328
with pytest.raises(
@@ -1011,11 +1011,11 @@ def test_child_pids(self):
10111011

10121012
master_pids = master.auxiliary_pids
10131013
for ptype in master_processes:
1014-
self.assertIn(ptype, master_pids)
1014+
assert (ptype in master_pids)
10151015

10161016
replica_pids = replica.auxiliary_pids
10171017
for ptype in repl_processes:
1018-
self.assertIn(ptype, replica_pids)
1018+
assert (ptype in replica_pids)
10191019

10201020
# there should be exactly 1 source walsender for replica
10211021
assert (len(master_pids[ProcessType.WalSender]) == 1)
@@ -1320,12 +1320,7 @@ def test_set_auto_conf(self):
13201320
content = f.read()
13211321

13221322
for x in testData:
1323-
self.assertIn(
1324-
x[0] + " = " + x[2],
1325-
content,
1326-
x[0] + " stored wrong"
1327-
)
1328-
1323+
assert x[0] + " = " + x[2] in content
13291324
@staticmethod
13301325
def helper__skip_test_if_util_not_exist(name: str):
13311326
assert type(name) == str # noqa: E721

tests/test_simple_remote.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ def test_safe_psql__expect_error(self):
377377
with get_remote_node(conn_params=conn_params).init().start() as node:
378378
err = node.safe_psql('select_or_not_select 1', expect_error=True)
379379
assert (type(err) == str) # noqa: E721
380-
self.assertIn('select_or_not_select', err)
381-
self.assertIn('ERROR: syntax error at or near "select_or_not_select"', err)
380+
assert ('select_or_not_select' in err)
381+
assert ('ERROR: syntax error at or near "select_or_not_select"' in err)
382382

383383
# ---------
384384
with pytest.raises(
@@ -1054,11 +1054,11 @@ def test_child_pids(self):
10541054

10551055
master_pids = master.auxiliary_pids
10561056
for ptype in master_processes:
1057-
self.assertIn(ptype, master_pids)
1057+
assert (ptype in master_pids)
10581058

10591059
replica_pids = replica.auxiliary_pids
10601060
for ptype in repl_processes:
1061-
self.assertIn(ptype, replica_pids)
1061+
assert (ptype in replica_pids)
10621062

10631063
# there should be exactly 1 source walsender for replica
10641064
assert (len(master_pids[ProcessType.WalSender]) == 1)

0 commit comments

Comments
 (0)
0