Fix reported bugbear: too broad exception assertion (#9753)

pull/9765/head
Andrew Morgan 2021-04-06 13:48:22 +01:00 committed by GitHub
parent 0ef321ff3b
commit 024f121b74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

1
changelog.d/9753.misc Normal file
View File

@ -0,0 +1 @@
Check that a `ConfigError` is raised, rather than simply `Exception`, when appropriate in homeserver config file generation tests.

View File

@ -20,6 +20,7 @@ from io import StringIO
import yaml import yaml
from synapse.config import ConfigError
from synapse.config.homeserver import HomeServerConfig from synapse.config.homeserver import HomeServerConfig
from tests import unittest from tests import unittest
@ -35,9 +36,9 @@ class ConfigLoadingTestCase(unittest.TestCase):
def test_load_fails_if_server_name_missing(self): def test_load_fails_if_server_name_missing(self):
self.generate_config_and_remove_lines_containing("server_name") self.generate_config_and_remove_lines_containing("server_name")
with self.assertRaises(Exception): with self.assertRaises(ConfigError):
HomeServerConfig.load_config("", ["-c", self.file]) HomeServerConfig.load_config("", ["-c", self.file])
with self.assertRaises(Exception): with self.assertRaises(ConfigError):
HomeServerConfig.load_or_generate_config("", ["-c", self.file]) HomeServerConfig.load_or_generate_config("", ["-c", self.file])
def test_generates_and_loads_macaroon_secret_key(self): def test_generates_and_loads_macaroon_secret_key(self):