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

Define public API of datalad_next.tests #619

Merged
merged 1 commit into from
Feb 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datalad_next/annexbackends/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import io

from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 4 in datalad_next/annexbackends/tests/test_base.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/annexbackends/tests/test_base.py#L4

Added line #L4 was not covered by tests
assert_raises,
eq_,
)
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/annexremotes/tests/test_archivist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from datalad_next.datasets import Dataset
from datalad_next.runners import CommandError

from datalad_next.tests.utils import assert_result_count
from datalad_next.tests import assert_result_count

Check warning on line 12 in datalad_next/annexremotes/tests/test_archivist.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/annexremotes/tests/test_archivist.py#L12

Added line #L12 was not covered by tests


@pytest.fixture(autouse=False, scope="function")
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/annexremotes/tests/test_uncurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from datalad_next.consts import on_windows
from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 6 in datalad_next/annexremotes/tests/test_uncurl.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/annexremotes/tests/test_uncurl.py#L6

Added line #L6 was not covered by tests
create_tree,
skip_if_on_windows,
skip_if_root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
)
from urllib.parse import quote as urlquote

from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 8 in datalad_next/commands/tests/test_create_sibling_webdav.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/commands/tests/test_create_sibling_webdav.py#L8

Added line #L8 was not covered by tests
assert_in,
assert_in_results,
assert_raises,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/commands/tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from datalad_next.exceptions import IncompleteResultsError
from datalad_next.utils import external_versions
from datalad_next.tests.utils import (
from datalad_next.tests import (
assert_in,
assert_in_results,
assert_raises,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/commands/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
credentials,
download,
)
from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 10 in datalad_next/commands/tests/test_download.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/commands/tests/test_download.py#L10

Added line #L10 was not covered by tests
assert_result_count,
assert_status,
)
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/commands/tests/test_ls_file_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from datalad_next.constraints.exceptions import CommandParametrizationError
# we need this fixture
from datalad_next.iter_collections.tests.test_iterzip import sample_zip
from datalad_next.tests.marker import skipif_no_network
from datalad_next.tests import skipif_no_network

Check warning on line 12 in datalad_next/commands/tests/test_ls_file_collection.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/commands/tests/test_ls_file_collection.py#L12

Added line #L12 was not covered by tests

from ..ls_file_collection import LsFileCollectionParamValidator

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/commands/tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CommandParametrizationError,
ParameterConstraintContext,
)
from datalad_next.tests.utils import chpwd
from datalad_next.utils import chpwd

Check warning on line 9 in datalad_next/commands/tests/test_status.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/commands/tests/test_status.py#L9

Added line #L9 was not covered by tests

from ..status import (
opt_eval_subdataset_state_values,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/commands/tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from os import sep

import pytest
from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 6 in datalad_next/commands/tests/test_tree.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/commands/tests/test_tree.py#L6

Added line #L6 was not covered by tests
BasicGitTestRepo,
assert_raises,
create_tree,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/credman/tests/test_credman.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
CredentialManager,
_get_cred_cfg_var,
)
from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 19 in datalad_next/credman/tests/test_credman.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/credman/tests/test_credman.py#L19

Added line #L19 was not covered by tests
assert_in,
assert_raises,
eq_,
Expand Down
4 changes: 2 additions & 2 deletions datalad_next/gitremotes/tests/test_datalad_annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
Dataset,
clone,
)
from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 22 in datalad_next/gitremotes/tests/test_datalad_annex.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/gitremotes/tests/test_datalad_annex.py#L22

Added line #L22 was not covered by tests
DEFAULT_BRANCH,
DEFAULT_REMOTE,
assert_raises,
assert_status,
eq_,
rmtree,
skip_if_root,
)
from datalad_next.consts import on_windows
from datalad_next.exceptions import CommandError
from datalad_next.utils import rmtree

Check warning on line 32 in datalad_next/gitremotes/tests/test_datalad_annex.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/gitremotes/tests/test_datalad_annex.py#L32

Added line #L32 was not covered by tests
from ..datalad_annex import get_initremote_params_from_url


Expand Down
6 changes: 4 additions & 2 deletions datalad_next/iter_collections/tests/test_iterdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from pathlib import PurePath
import pytest

from datalad_next.tests.utils import (
from datalad_next.tests import (

Check warning on line 5 in datalad_next/iter_collections/tests/test_iterdir.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_iterdir.py#L5

Added line #L5 was not covered by tests
create_tree,
)
from datalad_next.utils import (

Check warning on line 8 in datalad_next/iter_collections/tests/test_iterdir.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_iterdir.py#L8

Added line #L8 was not covered by tests
check_symlink_capability,
rmtree,
)
from datalad_next.utils import check_symlink_capability

from ..directory import (
DirectoryItem,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/tests/test_itergitdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import shutil

from datalad_next.tests.utils import rmtree
from datalad_next.utils import rmtree

Check warning on line 5 in datalad_next/iter_collections/tests/test_itergitdiff.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_itergitdiff.py#L5

Added line #L5 was not covered by tests

from ..gitdiff import (
GitTreeItemType,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/tests/test_itergittree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import pytest

from datalad_next.tests.utils import rmtree
from datalad_next.utils import rmtree

Check warning on line 8 in datalad_next/iter_collections/tests/test_itergittree.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_itergittree.py#L7-L8

Added lines #L7 - L8 were not covered by tests
from ..gittree import (
GitTreeItem,
GitTreeItemType,
Expand Down
7 changes: 4 additions & 3 deletions datalad_next/iter_collections/tests/test_itergitworktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import pytest

from datalad_next.utils import check_symlink_capability

from datalad_next.tests.utils import rmtree
from datalad_next.utils import (
check_symlink_capability,
rmtree,
)

from ..gitworktree import (
GitWorktreeItem,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/tests/test_itertar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from datalad.api import download

from datalad_next.tests.marker import skipif_no_network
from datalad_next.tests import skipif_no_network

Check warning on line 6 in datalad_next/iter_collections/tests/test_itertar.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_itertar.py#L6

Added line #L6 was not covered by tests

from ..tarfile import (
TarfileItem,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datalad_next.tests.utils import skip_wo_symlink_capability
from datalad_next.tests import skip_wo_symlink_capability

Check warning on line 2 in datalad_next/iter_collections/tests/test_utils.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/iter_collections/tests/test_utils.py#L1-L2

Added lines #L1 - L2 were not covered by tests
from ..utils import FileSystemItem


Expand Down
2 changes: 1 addition & 1 deletion datalad_next/patches/tests/test_cli_configoverrides.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datalad_next.utils import chpwd
from datalad_next.tests.utils import run_main
from datalad_next.tests import run_main


def test_cli_configoverrides(existing_dataset):
Expand Down
5 changes: 3 additions & 2 deletions datalad_next/patches/tests/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datalad_next.tests.utils import (
from datalad_next.tests import (
assert_in_results,
assert_raises,
chpwd,
)
from datalad_next.utils import chpwd

from datalad.api import configuration
from datalad_next.exceptions import IncompleteResultsError

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/patches/tests/test_push.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datalad_next.tests.utils import (
from datalad_next.tests import (
DEFAULT_REMOTE,
assert_result_count,
)
Expand Down
6 changes: 3 additions & 3 deletions datalad_next/patches/tests/test_push_to_export_remote.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pathlib import Path
import pytest

Check warning on line 2 in datalad_next/patches/tests/test_push_to_export_remote.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/patches/tests/test_push_to_export_remote.py#L2

Added line #L2 was not covered by tests
from typing import Generator
from unittest.mock import (
MagicMock,
call,
patch,
)

from datalad_next.tests.utils import (
SkipTest,
from datalad_next.tests import (

Check warning on line 10 in datalad_next/patches/tests/test_push_to_export_remote.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/patches/tests/test_push_to_export_remote.py#L10

Added line #L10 was not covered by tests
assert_in,
assert_in_results,
eq_,
Expand Down Expand Up @@ -230,7 +230,7 @@


def test_is_valid_treeish():
raise SkipTest(
pytest.skip(

Check warning on line 233 in datalad_next/patches/tests/test_push_to_export_remote.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/patches/tests/test_push_to_export_remote.py#L233

Added line #L233 was not covered by tests
"this test is skipped until issue "
"https://github.com/datalad/datalad-next/issues/39 is solved")

Expand Down
7 changes: 2 additions & 5 deletions datalad_next/patches/tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import pytest

from datalad_next.exceptions import IncompleteResultsError
from datalad_next.tests.utils import (
SkipTest,
assert_result_count,
)
from datalad_next.tests import assert_result_count


def test_substitution_config_default(existing_dataset, no_result_rendering):
ds = existing_dataset

if ds.config.get('datalad.run.substitutions.python') is not None:
# we want to test default handling when no config is set
raise SkipTest(
pytest.skip(
'Test assumptions conflict with effective configuration')

# the {python} placeholder is not explicitly defined, but it has
Expand Down
55 changes: 55 additions & 0 deletions datalad_next/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,0 +1,55 @@
"""Tooling for test implementations

.. currentmodule:: datalad_next.tests
.. autosummary::
:toctree: generated

BasicGitTestRepo
DEFAULT_BRANCH
DEFAULT_REMOTE
assert_in
assert_in_results
assert_result_count
assert_status
create_tree
eq_
get_deeply_nested_structure
ok_
ok_good_symlink
ok_broken_symlink
run_main
skip_if_on_windows
skip_if_root
skip_wo_symlink_capability
swallow_logs
skipif_no_network
"""
# TODO `assert_raises` is excluded above to avoid syntax errors in the docstring
# rather than fixing those, we should replace it with `pytest.raises` entirely

from .utils import (

Check warning on line 30 in datalad_next/tests/__init__.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/__init__.py#L30

Added line #L30 was not covered by tests
BasicGitTestRepo,
DEFAULT_BRANCH,
DEFAULT_REMOTE,
assert_in,
assert_in_results,
assert_raises,
assert_result_count,
assert_status,
create_tree,
eq_,
get_deeply_nested_structure,
ok_,
ok_good_symlink,
ok_broken_symlink,
run_main,
skip_if_on_windows,
skip_if_root,
skip_wo_symlink_capability,
swallow_logs,
)


from .marker import (

Check warning on line 53 in datalad_next/tests/__init__.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/__init__.py#L53

Added line #L53 was not covered by tests
skipif_no_network,
)
17 changes: 8 additions & 9 deletions datalad_next/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
call_git_lines,
call_git_success,
)
from datalad_next.tests.utils import (
from .utils import (

Check warning on line 19 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L19

Added line #L19 was not covered by tests
HTTPPath,
SkipTest,
WebDAVPath,
assert_ssh_access,
external_versions,
Expand Down Expand Up @@ -167,7 +166,7 @@
here was only introduced with that version.
"""
if external_versions['cmd:git'] < "2.32":
raise SkipTest(
pytest.skip(

Check warning on line 169 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L169

Added line #L169 was not covered by tests
"Git configuration redirect via GIT_CONFIG_GLOBAL "
"only supported since Git v2.32"
)
Expand Down Expand Up @@ -561,15 +560,15 @@
in some cases it is simply not desirable to run a test. For example,
the appveyor workers are more or less constantly unable to access the
public service. This fixture is evaluated at function-scope and
raises ``SkipTest`` whenever any of these undesired conditions is
skips the test whenever any of these undesired conditions is
detected. Otherwise it just relays ``httpbin_service``.
"""
if os.environ.get('DATALAD_TESTS_NONETWORK'):
raise SkipTest(
pytest.skip(

Check warning on line 567 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L567

Added line #L567 was not covered by tests
'Not running httpbin-based test: NONETWORK flag set'
)
if 'APPVEYOR' in os.environ and 'DEPLOY_HTTPBIN_IMAGE' not in os.environ:
raise SkipTest(
pytest.skip(

Check warning on line 571 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L571

Added line #L571 was not covered by tests
"Not running httpbin-based test on appveyor without "
"docker-deployed instance -- too unreliable"
)
Expand All @@ -591,7 +590,7 @@
> assert ... datalad_interactive_ui.log
"""
from datalad_next.uis import ui_switcher
from datalad_next.tests.utils import InteractiveTestUI
from .utils import InteractiveTestUI

Check warning on line 593 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L593

Added line #L593 was not covered by tests

with monkeypatch.context() as m:
m.setattr(ui_switcher, '_ui', InteractiveTestUI())
Expand All @@ -611,7 +610,7 @@
> assert ... datalad_interactive_ui.log
"""
from datalad_next.uis import ui_switcher
from datalad_next.tests.utils import TestUI
from .utils import TestUI

Check warning on line 613 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L613

Added line #L613 was not covered by tests

with monkeypatch.context() as m:
m.setattr(ui_switcher, '_ui', TestUI())
Expand All @@ -621,7 +620,7 @@
@pytest.fixture(autouse=False, scope="session")
def sshserver_setup(tmp_path_factory):
if not os.environ.get('DATALAD_TESTS_SSH'):
raise SkipTest(
pytest.skip(

Check warning on line 623 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L623

Added line #L623 was not covered by tests
"set DATALAD_TESTS_SSH=1 to enable")

# query a bunch of recognized configuration environment variables,
Expand Down
4 changes: 3 additions & 1 deletion datalad_next/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DEFAULT_BRANCH,
DEFAULT_REMOTE,
HTTPPath,
# TODO REMOVE FOR V2.0
SkipTest,
assert_in,
assert_in_results,
Expand All @@ -30,6 +31,7 @@
ok_broken_symlink,
ok_exists,
ok_good_symlink,
# TODO REMOVE FOR V2.0
rmtree,
skip_if_on_windows,
skip_if_root,
Expand Down Expand Up @@ -78,7 +80,7 @@ def __enter__(self):
from cheroot import wsgi
from wsgidav.wsgidav_app import WsgiDAVApp
except ImportError as e:
raise SkipTest('No WSGI capabilities. Install cheroot and/or wsgidav') from e
pytest.skip(f'No WSGI capabilities. Install cheroot and/or wsgidav ({e!r})')

if self.auth:
auth = {self.auth[0]: {'password': self.auth[1]}}
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/url_operations/tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
import requests

from datalad_next.tests.marker import skipif_no_network
from datalad_next.tests import skipif_no_network

from ..any import AnyUrlOperations
from ..http import (
Expand Down
Loading
Loading