Skip to content

Commit 2cd00c4

Browse files
committed
Use assertEndsWith from test.support.testcase.ExtraAssertions
1 parent 23e4b3c commit 2cd00c4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Lib/test/test_sqlite3/test_cli.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
from sqlite3.__main__ import main as cli
66
from test.support.os_helper import TESTFN, unlink
7+
from test.support.testcase import ExtraAssertions
78
from test.support import captured_stdout, captured_stderr, captured_stdin
89

910

10-
class CommandLineInterface(unittest.TestCase):
11+
class CommandLineInterface(unittest.TestCase, ExtraAssertions):
1112

1213
def _do_test(self, *args, expect_success=True):
1314
with (
@@ -88,22 +89,22 @@ def test_interact(self):
8889
out, err = self.run_cli()
8990
self.assertIn(self.MEMORY_DB_MSG, err)
9091
self.assertIn(self.MEMORY_DB_MSG, err)
91-
self.assertTrue(out.endswith(self.PS1))
92+
self.assertEndsWith(out, self.PS1)
9293
self.assertEqual(out.count(self.PS1), 1)
9394
self.assertEqual(out.count(self.PS2), 0)
9495

9596
def test_interact_quit(self):
9697
out, err = self.run_cli(commands=(".quit",))
9798
self.assertIn(self.MEMORY_DB_MSG, err)
98-
self.assertTrue(out.endswith(self.PS1))
99+
self.assertEndsWith(out, self.PS1)
99100
self.assertEqual(out.count(self.PS1), 1)
100101
self.assertEqual(out.count(self.PS2), 0)
101102

102103
def test_interact_version(self):
103104
out, err = self.run_cli(commands=(".version",))
104105
self.assertIn(self.MEMORY_DB_MSG, err)
105106
self.assertIn(sqlite3.sqlite_version + "\n", out)
106-
self.assertTrue(out.endswith(self.PS1))
107+
self.assertEndsWith(out, self.PS1)
107108
self.assertEqual(out.count(self.PS1), 2)
108109
self.assertEqual(out.count(self.PS2), 0)
109110
self.assertIn(sqlite3.sqlite_version, out)
@@ -144,14 +145,14 @@ def test_interact_valid_sql(self):
144145
out, err = self.run_cli(commands=("SELECT 1;",))
145146
self.assertIn(self.MEMORY_DB_MSG, err)
146147
self.assertIn("(1,)\n", out)
147-
self.assertTrue(out.endswith(self.PS1))
148+
self.assertEndsWith(out, self.PS1)
148149
self.assertEqual(out.count(self.PS1), 2)
149150
self.assertEqual(out.count(self.PS2), 0)
150151

151152
def test_interact_incomplete_multiline_sql(self):
152153
out, err = self.run_cli(commands=("SELECT 1",))
153154
self.assertIn(self.MEMORY_DB_MSG, err)
154-
self.assertTrue(out.endswith(self.PS2))
155+
self.assertEndsWith(out, self.PS2)
155156
self.assertEqual(out.count(self.PS1), 1)
156157
self.assertEqual(out.count(self.PS2), 1)
157158

@@ -160,15 +161,15 @@ def test_interact_valid_multiline_sql(self):
160161
self.assertIn(self.MEMORY_DB_MSG, err)
161162
self.assertIn(self.PS2, out)
162163
self.assertIn("(1,)\n", out)
163-
self.assertTrue(out.endswith(self.PS1))
164+
self.assertEndsWith(out, self.PS1)
164165
self.assertEqual(out.count(self.PS1), 2)
165166
self.assertEqual(out.count(self.PS2), 1)
166167

167168
def test_interact_invalid_sql(self):
168169
out, err = self.run_cli(commands=("sel;",))
169170
self.assertIn(self.MEMORY_DB_MSG, err)
170171
self.assertIn("OperationalError (SQLITE_ERROR)", err)
171-
self.assertTrue(out.endswith(self.PS1))
172+
self.assertEndsWith(out, self.PS1)
172173
self.assertEqual(out.count(self.PS1), 2)
173174
self.assertEqual(out.count(self.PS2), 0)
174175

@@ -177,7 +178,7 @@ def test_interact_on_disk_file(self):
177178

178179
out, err = self.run_cli(TESTFN, commands=("CREATE TABLE t(t);",))
179180
self.assertIn(TESTFN, err)
180-
self.assertTrue(out.endswith(self.PS1))
181+
self.assertEndsWith(out, self.PS1)
181182

182183
out, _ = self.run_cli(TESTFN, commands=("SELECT count(t) FROM t;",))
183184
self.assertIn("(0,)\n", out)

0 commit comments

Comments
 (0)