Commit 1c08a88c authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Start with pytest

parent 06cf43fe
pytest
\ No newline at end of file
import os
from distutils.dir_util import copy_tree
from pathlib import Path
......@@ -9,4 +8,4 @@ SKEL_PATH = Path(__file__).absolute().parents[1] / Path("skeleton")
def initialize():
"""Initialize a nbcourse directory"""
copy_tree(SKEL_PATH, os.getcwd())
copy_tree(SKEL_PATH, str(Path.cwd()))
../skeleton
\ No newline at end of file
import nbcourse
from nbcourse.quickstart import initialize
import contextlib
from pathlib import Path
import os
def test_initialize(tmpdir):
"""Test if initialize function creates the right project skeleton"""
# Get skeleton content
skeleton_path = Path(nbcourse.__path__[0]) / Path("skeleton")
skeleton_paths = set((path.relative_to(skeleton_path)
for path in skeleton_path.glob('**/*')))
# Create a temporary project dir
p = tmpdir.mkdir("test_project")
os.chdir(p)
# Initialize and compare
initialize()
paths = set((path.relative_to(p) for path in Path(p).glob('**/*')))
assert paths == skeleton_paths
from nbcourse.utils import update_dict
import os
from pprint import pprint
import pytest
def test_update_dict():
cur = {'1-a': 1,
'1-b': {'2-a': 2,
'2-b': {'3-a': 3}
}
}
new = {'1-a': 11,
'1-c': 0,
'1-b': {'2-b': {'3-a': 31},
'2-c': 0
},
'1-d': {'2-d': 0}
}
update_dict(cur, new)
ref = {'1-a': 11,
'1-b': {'2-a': 2,
'2-b': {'3-a': 31},
'2-c': 0},
'1-c': 0,
'1-d': {'2-d': 0}}
assert cur == ref
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