From b145bd581a51daae7c9a6eb1bb44b078bb76b6d9 Mon Sep 17 00:00:00 2001 From: Joe Runde Date: Thu, 27 Apr 2023 15:55:40 -0600 Subject: [PATCH] :technologist: Add better assertion messages Signed-off-by: Joe Runde --- aconfig/aconfig.py | 4 ++-- test/test_config.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aconfig/aconfig.py b/aconfig/aconfig.py index e40aca9..e523d18 100644 --- a/aconfig/aconfig.py +++ b/aconfig/aconfig.py @@ -213,10 +213,10 @@ def _verify_config_location(config_location): config_location = os.path.normpath(config_location) assert (config_location.endswith('.yml') or config_location.endswith('.yaml')), \ - 'Must send in a .yaml or .yaml file' + 'Must send in a .yaml or .yaml file, you sent in: <{0}>'.format(config_location) assert os.path.exists(config_location), \ - 'config_location does not exist or cannot be found!' + 'config_location <{0}> does not exist or cannot be found!'.format(config_location) # finally found it's valid return config_location diff --git a/test/test_config.py b/test/test_config.py index a619205..228dfac 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -48,6 +48,7 @@ def test__verify_config_location_fail(self): bad_config2 = aconfig.Config._verify_config_location(fixtures.BAD_CONFIG_LOCATION) raised_exception2 = ex2.exception self.assertIsInstance(raised_exception2, AssertionError) + self.assertIn(fixtures.BAD_CONFIG_LOCATION, str(ex2.exception)) # make sure bad_config2 was NOT initialized self.assertEqual(getattr(locals(), 'bad_config2', None), None) @@ -56,6 +57,7 @@ def test__verify_config_location_fail(self): bad_config3 = aconfig.Config._verify_config_location(fixtures.NOT_YAML_CONFIG_LOCATION) raised_exception3 = ex3.exception self.assertIsInstance(raised_exception3, AssertionError) + self.assertIn(fixtures.NOT_YAML_CONFIG_LOCATION, str(ex3.exception)) # make sure bad_config3 was NOT initialized self.assertEqual(getattr(locals(), 'bad_config3', None), None)