The config module had a large amount of globals that were being
touched across many modules that would import. This made changes to
config very fragile as figuring out what would be modified in any
given call chain was difficult to diagnose.
It also made testing fragile as one would need to reset a given
module's config import to the best of their knowledge before rerunning
another test.
To get away from that (and to try and reduce the number of globally
modified variablies in autospec as a whole), refactor the config
module to provide its state as part config class. The long running
goal of changes like this is to better track what content can be
updated by a particular function (if a function would have access
to the config instance is now the hint rather than the config module
getting imported).
Some changes have recently been pushed to autospec sources without
updating the unit tests. This patch brings the unit tests up-to-date
again.
test_build.py: Remove go buildtool bits (was deprecated)
test_specdescription.py: Newline added to post-scripts
test_specfile.py: Reset license_translations dict
files.py: Check dict with get() in case of missing key
Clean up the specdescription module, including resolving two bugs and
making the code more readable and more robust.
BUGS:
- description_from_pkginfo
A string was checked for a substring using the string.find() method
but was treated as a boolean, assuming that find() returned 0 when the
substring was not found. This was causing a section end to be
immediately detected and the section was not parsed. The call was
replaced with the `in` keyword.
- description_from_spec
The default description was overwritten regardless of whether the
detected description had any content. A check was added to only
overwrite the default if there was a detected description.
Other general cleanup:
- Remove unused default_group global
- Remove unused argument in summary_from_R
- Add assign_summary/description methods to reduce global usage and
reduce code repetition
- Add function docstrings
- Convert to `with open()` blocks when working with files instead of
explicitly handling closing the files
- Wrap open() calls in try...catch blocks
Unit tests added for the specdescription module. At the time of this
commit, there are two failing tests due to bugs in the module.
Failures:
- test_description_from_pkginfo
This test fails because a string.find() method is checked as a boolean
as if find returned 0 if the substring was not present. find()
actually returns -1 in this case. Because find() was being used as a
guard to find the end of a section, the end was found immediately and
the section was not parsed.
- test_description_from_spec_no_info
This test fails due to the default description being overridden, even
when the override is just an empty string.