diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-08-03 10:31:55 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-08-03 10:33:52 +0200 |
| commit | c7060912256cc9af6d01d2cedd7f7b9b1efd8890 (patch) | |
| tree | 49527a1bc245a41f791386afcfa2796768bb490a /tests/backends/postgresql | |
| parent | a004350193a503b6722633c4309f70551fde0983 (diff) | |
[2.1.x] Fixed #29613 -- Fixed --keepdb on PostgreSQL if the database exists and the user can't create databases.
Regression in e776dd2db677d58dcb50aea20d3bb191537df25b.
Thanks Tim Graham for the review.
Backport of 1a9cbf41a130def83a7e384955544d08be0fc148 from master
Diffstat (limited to 'tests/backends/postgresql')
| -rw-r--r-- | tests/backends/postgresql/test_creation.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/backends/postgresql/test_creation.py b/tests/backends/postgresql/test_creation.py index 9f51d5e6b2..7d6f319a80 100644 --- a/tests/backends/postgresql/test_creation.py +++ b/tests/backends/postgresql/test_creation.py @@ -89,7 +89,14 @@ class DatabaseCreationTests(SimpleTestCase): creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True) # Simulate test database creation raising unexpected error with self.patch_test_db_creation(self._execute_raise_permission_denied): - with self.assertRaises(SystemExit): - creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False) - with self.assertRaises(SystemExit): + with mock.patch.object(DatabaseCreation, '_database_exists', return_value=False): + with self.assertRaises(SystemExit): + creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False) + with self.assertRaises(SystemExit): + creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True) + # Simulate test database creation raising "insufficient privileges". + # An error shouldn't appear when keepdb is on and the database already + # exists. + with self.patch_test_db_creation(self._execute_raise_permission_denied): + with mock.patch.object(DatabaseCreation, '_database_exists', return_value=True): creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True) |
