Skip to content

Commit

Permalink
Support unexistant output directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryneeverett committed Jan 5, 2016
1 parent b2a293e commit f27664b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mkcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@ def main(inputs, output, github, safe):
inputname = os.path.splitext(os.path.basename(filename))[0]
outputfilename = output.format(name=inputname)

outputdir = os.path.dirname(outputfilename)
if not os.path.exists(outputdir):
os.makedirs(outputdir)

with open(outputfilename, 'w') as outputfile:
outputfile.write(code)
15 changes: 15 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil
import textwrap
import unittest
import subprocess
Expand Down Expand Up @@ -94,6 +95,20 @@ def test_multiple(self):
self.remove('tests/some.py')
self.remove('tests/other.py')

def test_unexistant_output_directory(self):
try:
subprocess.call([
'mkcodes', '--output', 'tests/unexistant/{name}.py',
'--github', 'tests/data/some.md'])
self.assertFileEqual('tests/unexistant/some.py', """\
bar = False
backticks = range(5, 7)
""")
finally:
shutil.rmtree('tests/unexistant')

@unittest.skip
def test_glob(self):
raise NotImplementedError
Expand Down

0 comments on commit f27664b

Please sign in to comment.