Summary: | ASTERISK-27894: [patch] testsuite: Avoid KeyError when astdatadir not set in asterisk.conf. | ||
Reporter: | Alexander Traud (traud) | Labels: | patch |
Date Opened: | 2018-06-05 03:34:26 | Date Closed: | 2018-06-08 01:22:11 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Tests/testsuite |
Versions: | 13.21.0 15.4.0 | Frequency of Occurrence | |
Related Issues: | |||
Environment: | configs/basic-pbx | Attachments: | ( 0) astdatadir.patch |
Description: | Currently, the Asterisk Test Suite requires the parameter {{astdatadir}} to be set in the configuration file {{asterisk.conf}}. Consequently, with {{sudo make basic-pbx}} for example, {{./runtests.py -l}} gives:{code} File "./runtests.py", line 68, in <module>
astdatadir = ast_config.directories["astdatadir"] or '/var/lib/asterisk' KeyError: 'astdatadir'{code}This is because a misunderstanding of the Python code: The standard Python class [dict|http://docs.python.org/2.7/library/stdtypes.html#typesmapping] raises an exception—here {{KeyError}}—when the key—here {{astdatadir}}—is not present in the directory at all. Consequently, the part after 'or' is not even evaluated. The solution is to go for {{dict.get}} which goes for a default value on a KeyError. This issue was reported by [Jaco Kroon|http://infobot.rikers.org/%23asterisk-dev/20160427.html.gz] and [Colin Sung|https://github.com/asterisk/testsuite/pull/1/commits/06f196ad9c2b827810bf7cbba41a85cacee8a993]. The attached patch changes from {{dict\[key\]}} to {{dict.get(key, default)}} and originates from Colin Sung, actually. | ||
Comments: | By: Asterisk Team (asteriskteam) 2018-06-05 03:34:28.999-0500 Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report. Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. |