Commit bb335abb authored by Jaap Roes's avatar Jaap Roes

Added tests (and made them pass) for update_versions_file's output.

parent f0b0aa45
......@@ -135,7 +135,7 @@ def _format_picked_versions(picked_versions, required_by):
target = output
target.append("%s = %s" % (dist_, version))
output.extend(required_output)
return '\n'.join(output)
return output
_buildout_default_options = _annotate_section({
......@@ -1017,16 +1017,18 @@ class Buildout(DictMixin):
if self.show_picked_versions:
print_("Versions had to be automatically picked.")
print_("The following part definition lists the versions picked:")
print_(output)
print_('\n'.join(output))
if self.update_versions_file:
# Write to the versions file.
if os.path.exists(self.update_versions_file):
output += ('\n# Added by buildout at %s' %
datetime.datetime.now())
output += '\n'
output[:1] = [
'',
'# Added by buildout at %s' % datetime.datetime.now()
]
output.append('')
f = open(self.update_versions_file, 'a')
f.write(output)
f.write(('\n'.join(output)))
f.close()
print_("Picked versions have been written to " +
self.update_versions_file)
......
......@@ -368,8 +368,13 @@ at the end.
The versions file now contains the extra pin:
>>> 'spam = 2' in open('my_versions.cfg').read()
True
>>> print_(open('my_versions.cfg').read()) # doctest: +ELLIPSIS
<BLANKLINE>
...
<BLANKLINE>
# Added by buildout at YYYY-MM-DD hh:mm:ss.dddddd
spam = 2
<BLANKLINE>
And re-running buildout doesn't report any picked versions anymore:
......@@ -405,8 +410,13 @@ printing them to the console):
The versions file contains the extra pin:
>>> 'spam = 2' in open('my_versions.cfg').read()
True
>>> print_(open('my_versions.cfg').read()) # doctest: +ELLIPSIS
<BLANKLINE>
...
<BLANKLINE>
# Added by buildout at YYYY-MM-DD hh:mm:ss.dddddd
spam = 2
<BLANKLINE>
Because buildout now includes buildout-versions' (and part of the older
buildout.dumppickedversions') functionality, it warns if these extensions are
......
......@@ -3293,7 +3293,9 @@ def test_suite():
),
(re.compile('executable = %s' % re.escape(sys.executable)),
'executable = python'),
])
(re.compile(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}'),
'YYYY-MM-DD hh:mm:ss.dddddd'),
]),
),
doctest.DocFileSuite(
'debugging.txt',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment