Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests now have setup and teardown #13

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions asekuro/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def _cwd(nbpath):
logger.debug(f"directory of script calling {os.getcwd()}")
folder = os.path.dirname(nbpath)
filename = os.path.basename(nbpath)
if folder == "":
folder = os.getcwd()
os.chdir(folder)
logger.debug(f"directory for rest of script {os.getcwd()}")
return folder, filename
Expand Down
30 changes: 29 additions & 1 deletion tests/test_commandline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import os
import subprocess

from asekuro.commandline import _testfile

class TestCommandLine:
class TestPathHandlingLocal:

@classmethod
def setup_class(cls):
os.chdir("tests")

@classmethod
def teardown_class(cls):
os.chdir("..")

def test_tempfile_creation(self):
assert _testfile("foobar.ipynb") == "foobar-test.ipynb"

def test_good_nb(self):
status = subprocess.call(['asekuro', 'test', 'good-nb.ipynb'])
assert status == 0

def test_data_nb(self):
status = subprocess.call(['asekuro', 'test', 'data-nb.ipynb'])
assert status == 0

def test_bad_bn(self):
status = subprocess.call(['asekuro', 'test', 'bad-nb.ipynb'])
assert status == 2


class TestCommandLineOuter:

def test_good_nb(self):
status = subprocess.call(['asekuro', 'test', 'tests/good-nb.ipynb'])
Expand Down