# HG changeset patch # User Jeff Hammel # Date 1293958138 28800 # Node ID 6b4c8f23192ff2dafbdd2bf06620af01e5eaf317 # Parent a2cdce0108e11e199fdc4de0367ae7d750397e6e test and fix mixed output case diff -r a2cdce0108e1 -r 6b4c8f23192f examples/doctest.txt --- a/examples/doctest.txt Sat Jan 01 23:00:59 2011 -0800 +++ b/examples/doctest.txt Sun Jan 02 00:48:58 2011 -0800 @@ -56,4 +56,24 @@ Mixed case: >>> template = makeitso.PolyTemplate([example, exampledir]) + >>> variables = sorted(template.missing()) + >>> variables + ['bar', 'foo', 'name', 'subdir'] +You need to provide output for mixing files and directory templates: + + >>> variables = dict([(i, i.title()) for i in variables]) + >>> try: + ... template.substitute(**variables) + ... except AssertionError, e: + ... pass + >>> e + AssertionError('Must specify output ... + +Provide an output: + + >>> template = makeitso.PolyTemplate([example, exampledir], output=tempdir, interactive=False) + >>> template.substitute(**variables) + >>> sorted(os.listdir(tempdir)) + ['Subdir', 'example.txt', 'foo.txt'] + >>> shutil.rmtree(tempdir) diff -r a2cdce0108e1 -r 6b4c8f23192f examples/test.py --- a/examples/test.py Sat Jan 01 23:00:59 2011 -0800 +++ b/examples/test.py Sun Jan 02 00:48:58 2011 -0800 @@ -12,7 +12,10 @@ extraglobs = {'here': directory} tests = [ 'doctest.txt' ] for test in tests: - doctest.testfile(test, extraglobs=extraglobs, raise_on_error=False) + doctest.testfile(test, + optionflags=doctest.ELLIPSIS, + extraglobs=extraglobs, + raise_on_error=False) if __name__ == '__main__': run_tests() diff -r a2cdce0108e1 -r 6b4c8f23192f makeitso/makeitso.py --- a/makeitso/makeitso.py Sat Jan 01 23:00:59 2011 -0800 +++ b/makeitso/makeitso.py Sun Jan 02 00:48:58 2011 -0800 @@ -315,7 +315,7 @@ # determine where the hell to put these things if self.output is None: dirs = [i for i in self._templates if os.path.isdir(i)] - if not ((len(dirs) == 0) or len(dirs) == len(templates)): + if not ((len(dirs) == 0) or len(dirs) == len(self.templates)): raise AssertionError("Must specify output when mixing directories and URIs") # TODO: check for missing