Skip to content

Add basic test for skip_if_exists #60

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

Merged
merged 1 commit into from
Dec 18, 2020
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
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import shutil
import pathlib
from pytest import fixture

Expand Down
24 changes: 24 additions & 0 deletions tests/test_skip_if_exists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

from jupyter_packaging.setupbase import skip_if_exists, BaseCommand
from utils import run_command


class TestCommand(BaseCommand):
def run(self):
raise RuntimeError()


def test_skip_existing(destination_dir):
local_targets = ['file1.rtf', 'sub/subfile1.rtf']
targets = [str(destination_dir.join(t)) for t in local_targets]
cmd = skip_if_exists(targets, TestCommand)
run_command(cmd)


def test_no_skip_missing(source_dir):
local_targets = ['file1.rtf', 'sub/subfile1.rtf']
targets = [str(source_dir.join(t)) for t in local_targets]
cmd = skip_if_exists(targets, TestCommand)
with pytest.raises(RuntimeError):
run_command(cmd)