Skip to content

Commit

Permalink
Merge pull request #13 from godatadriven/only-one-file-bug
Browse files Browse the repository at this point in the history
tests now have setup and teardown
  • Loading branch information
koaning committed Jul 31, 2018
2 parents f47805e + 77733e0 commit 63eb25b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit 63eb25b

Please sign in to comment.