def test_test_makefile(): setup() n.assert_raises(AssertionError, check_sprint.test_has_makefile) open('Makefile', 'w').write('') n.assert_raises(AssertionError, check_sprint.test_has_makefile) open('Makefile', 'w').write('.PHONY: test\ntest:\n urchin test') check_sprint.test_has_makefile()
def test_directories(): "The appropriate directories should be created." setup() init.directories() for directory in ["code", "lib", "test"]: yield n.assert_true, os.path.isdir(directory) yield n.assert_true, os.path.isfile(os.path.join(directory, ".gitignore"))
def test_existing_file_is_ok(): 'If some skeleton files already exist, init should quietly skip them.' banana = 'I am a banana.' setup() open('readme.md', 'w').write(banana) init.readme() n.assert_equal(open('readme.md').read(), banana)
def test_existing_file_is_ok(): "If some skeleton files already exist, init should quietly skip them." banana = "I am a banana." setup() open("readme.md", "w").write(banana) init.readme() n.assert_equal(open("readme.md").read(), banana)
def test_directories(): 'The appropriate directories should be created.' setup() init.directories() for directory in ['code', 'lib', 'test']: yield n.assert_true, os.path.isdir(directory) yield n.assert_true, os.path.isfile( os.path.join(directory, '.gitignore'))
def test_readme(): "A readme should be created with the appropriate sections." setup() init.readme() yield n.assert_true, os.path.isfile("readme.md") readme = open("readme.md").read() for section in ["Overview", "References", "Goals", "Assignment", "Extra Credit", "Glossary"]: yield n.assert_in, "\n## %s" % section, readme
def test_add_gitignore(): setup() init.gitignore() gitignore = open('.gitignore').read() n.assert_in('*.pyc', gitignore) n.assert_in('.urchin.log', gitignore) open('.gitignore', 'w').write('chainsaw') init.gitignore() gitignore = open('.gitignore').read() n.assert_equal('chainsaw', gitignore)
def test_test_shell_files_correspond(): setup() check_sprint.test_shell_files_correspond() os.mkdir('code') os.mkdir('test') open(os.path.join('code', 'foo.sh'), 'w').write('') n.assert_raises(AssertionError, check_sprint.test_shell_files_correspond) open(os.path.join('test', 'foo.sh'), 'w').write('') check_sprint.test_shell_files_correspond()
def test_add_gitignore(): setup() init.gitignore() gitignore = open(".gitignore").read() n.assert_in("*.pyc", gitignore) n.assert_in(".urchin.log", gitignore) open(".gitignore", "w").write("chainsaw") init.gitignore() gitignore = open(".gitignore").read() n.assert_equal("chainsaw", gitignore)
def test_readme(): 'A readme should be created with the appropriate sections.' setup() init.readme() yield n.assert_true, os.path.isfile('readme.md') readme = open('readme.md').read() for section in [ 'Overview', 'References', 'Goals', 'Assignment', 'Extra Credit', 'Glossary' ]: yield n.assert_in, '\n## %s' % section, readme
def test_test_python_init(): setup() os.mkdir('code') os.mkdir('test') check_sprint.test_python_init() open(os.path.join('code', 'foo.py'), 'w').write('foo') n.assert_raises(AssertionError, check_sprint.test_python_init) os.remove(os.path.join('code', 'foo.py')) open(os.path.join('code', '__init__.py'), 'w').write('foo') check_sprint.test_python_init()
def test_test_python_files_correspond(): setup() check_sprint.test_python_files_correspond() os.mkdir('code') os.mkdir('test') open(os.path.join('code', 'foo.py'), 'w').write('') open(os.path.join('code', '__init__.py'), 'w').write('') n.assert_raises(AssertionError, check_sprint.test_python_files_correspond) open(os.path.join('test', 'test_foo.py'), 'w').write('') check_sprint.test_python_files_correspond()
def test_existing_dir_is_ok(): 'If some skeleton files already exist, init should quietly skip them.' setup() os.mkdir('code') init.directories()
def test_test_has_a_test(): setup() n.assert_raises(AssertionError, check_sprint.test_has_a_test) os.mkdir('test') open(os.path.join('test', 'foo'), 'w').write('') check_sprint.test_has_a_test()
def test_existing_dir_is_ok(): "If some skeleton files already exist, init should quietly skip them." setup() os.mkdir("code") init.directories()