Skip to content

Commit

Permalink
TST: Work around some worktree-related failures
Browse files Browse the repository at this point in the history
Based on local testing, three tests fail with an
InvalidGitRepositoryError when executed from within a git worktree of
the codebase: test_create_sibling.test_invalid_call,
test_run_procedure.test_invalid_call (dataladgh-3052), and
test_run_procedure.test_procedure_discovery.

Re: datalad#3029
Fixes datalad#3052.
  • Loading branch information
kyleam committed Jan 28, 2019
1 parent 5e37f0b commit 5c343e1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
19 changes: 12 additions & 7 deletions datalad/distribution/tests/test_create_sibling.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ def _test_correct_publish(target_path, rootds=False, flat=True):

@with_tempfile(mkdir=True)
def test_invalid_call(path):
# needs a SSH URL
assert_raises(InsufficientArgumentsError, create_sibling, '')
assert_raises(ValueError, create_sibling, 'http://ignore.me')
# needs an actual dataset
assert_raises(
ValueError,
create_sibling, 'localhost:/tmp/somewhere', dataset='/nothere')
with chpwd(path):
# ^ Change directory so that we don't fail with an
# InvalidGitRepositoryError if the test is executed from a git
# worktree.

# needs a SSH URL
assert_raises(InsufficientArgumentsError, create_sibling, '')
assert_raises(ValueError, create_sibling, 'http://ignore.me')
# needs an actual dataset
assert_raises(
ValueError,
create_sibling, 'localhost:/tmp/somewhere', dataset='/nothere')
# pre-configure a bogus remote
ds = Dataset(path).create()
ds.repo.add_remote('bogus', 'http://bogus.url.com')
Expand Down
43 changes: 27 additions & 16 deletions datalad/interface/tests/test_run_procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os.path as op

from datalad.utils import chpwd
from datalad.tests.utils import ok_clean_git
from datalad.tests.utils import eq_
from datalad.tests.utils import ok_file_has_content
Expand All @@ -34,12 +35,18 @@
from datalad import cfg


def test_invalid_call():
# needs spec or discover
assert_raises(InsufficientArgumentsError, run_procedure)
res = run_procedure('unknown', on_failure='ignore')
assert_true(len(res) == 1)
assert_in_results(res, status="impossible")
@with_tempfile(mkdir=True)
def test_invalid_call(path):
with chpwd(path):
# ^ Change directory so that we don't fail with an
# InvalidGitRepositoryError if the test is executed from a git
# worktree.

# needs spec or discover
assert_raises(InsufficientArgumentsError, run_procedure)
res = run_procedure('unknown', on_failure='ignore')
assert_true(len(res) == 1)
assert_in_results(res, status="impossible")


# FIXME: For some reason fails to commit correctly if on windows and in direct
Expand Down Expand Up @@ -112,16 +119,20 @@ def test_basics(path, super_path):
"""}})
@with_tempfile
def test_procedure_discovery(path, super_path):
ps = run_procedure(discover=True)
# there are a few procedures coming with datalad, needs to find them
assert_true(len(ps) > 2)
# we get three essential properties
eq_(
sum(['procedure_type' in p and
'procedure_callfmt' in p and
'path' in p
for p in ps]),
len(ps))
with chpwd(path):
# ^ Change directory so that we don't fail with an
# InvalidGitRepositoryError if the test is executed from a git
# worktree.
ps = run_procedure(discover=True)
# there are a few procedures coming with datalad, needs to find them
assert_true(len(ps) > 2)
# we get three essential properties
eq_(
sum(['procedure_type' in p and
'procedure_callfmt' in p and
'path' in p
for p in ps]),
len(ps))

# set up dataset with registered procedure (c&p from test_basics):
ds = Dataset(path).create(force=True)
Expand Down

0 comments on commit 5c343e1

Please sign in to comment.