mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface (GH-133440)
This commit is contained in:
parent
5044e85265
commit
ebd4881db2
3 changed files with 53 additions and 11 deletions
|
@ -116,6 +116,38 @@ class InteractiveSession(unittest.TestCase):
|
|||
self.assertEqual(out.count(self.PS2), 0)
|
||||
self.assertIn(sqlite3.sqlite_version, out)
|
||||
|
||||
def test_interact_empty_source(self):
|
||||
out, err = self.run_cli(commands=("", " "))
|
||||
self.assertIn(self.MEMORY_DB_MSG, err)
|
||||
self.assertEndsWith(out, self.PS1)
|
||||
self.assertEqual(out.count(self.PS1), 3)
|
||||
self.assertEqual(out.count(self.PS2), 0)
|
||||
|
||||
def test_interact_dot_commands_unknown(self):
|
||||
out, err = self.run_cli(commands=(".unknown_command", ))
|
||||
self.assertIn(self.MEMORY_DB_MSG, err)
|
||||
self.assertEndsWith(out, self.PS1)
|
||||
self.assertEqual(out.count(self.PS1), 2)
|
||||
self.assertEqual(out.count(self.PS2), 0)
|
||||
self.assertIn("Error", err)
|
||||
# test "unknown_command" is pointed out in the error message
|
||||
self.assertIn("unknown_command", err)
|
||||
|
||||
def test_interact_dot_commands_empty(self):
|
||||
out, err = self.run_cli(commands=("."))
|
||||
self.assertIn(self.MEMORY_DB_MSG, err)
|
||||
self.assertEndsWith(out, self.PS1)
|
||||
self.assertEqual(out.count(self.PS1), 2)
|
||||
self.assertEqual(out.count(self.PS2), 0)
|
||||
|
||||
def test_interact_dot_commands_with_whitespaces(self):
|
||||
out, err = self.run_cli(commands=(".version ", ". version"))
|
||||
self.assertIn(self.MEMORY_DB_MSG, err)
|
||||
self.assertEqual(out.count(sqlite3.sqlite_version + "\n"), 2)
|
||||
self.assertEndsWith(out, self.PS1)
|
||||
self.assertEqual(out.count(self.PS1), 3)
|
||||
self.assertEqual(out.count(self.PS2), 0)
|
||||
|
||||
def test_interact_valid_sql(self):
|
||||
out, err = self.run_cli(commands=("SELECT 1;",))
|
||||
self.assertIn(self.MEMORY_DB_MSG, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue