Skip to content

Instantly share code, notes, and snippets.

@goodwillcoding
Last active December 11, 2015 23:59
Show Gist options
  • Save goodwillcoding/4680942 to your computer and use it in GitHub Desktop.
Save goodwillcoding/4680942 to your computer and use it in GitHub Desktop.
from os import makedirs
from unittest import TestCase
def foo(_default_folder='foo', _os_makedirs=makedirs):
"""
The purpose of this function is to create a folder called 'foo'
on the file system.
"""
try:
_os_makedirs(_default_folder)
except EnvironmentError as err:
return 1
class Test_foo(TestCase):
def _callFUT(*args, **kwargs):
return foo(*args, **kwargs)
def test_foo():
test_folder = 'test_folder'
dummy_dir_entry = []
def dummy_os_makedirs(path):
dummy_dir_entry = path
desired_created_folder = test_folder
self._callFUT(_default_folder = test_folder, _os_makedirs = dummy_os_makedirs)
self.assertEqual(dummy_dir_entry, desired_created_folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment