Skip to content

Commit

Permalink
Updates tests to Python 3.7/3.10, as 2.7/3.6 being EOL
Browse files Browse the repository at this point in the history
Also migrate to the test packages from the ctools channel.
  • Loading branch information
dbast committed Jan 21, 2022
1 parent cc6705f commit 58e2e5e
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 140 deletions.
10 changes: 5 additions & 5 deletions conda_pack/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
croot = os.path.join(test_dir, '..', '..', 'testing', 'conda')
env_dir = os.path.join(os.path.abspath(croot), 'envs')

py27_path = os.path.join(env_dir, 'py27')
py36_path = os.path.join(env_dir, 'py36')
py36_editable_path = os.path.join(env_dir, 'py36_editable')
py36_broken_path = os.path.join(env_dir, 'py36_broken')
py36_missing_files_path = os.path.join(env_dir, 'py36_missing_files')
py37_path = os.path.join(env_dir, 'py37')
py37_editable_path = os.path.join(env_dir, 'py37_editable')
py37_broken_path = os.path.join(env_dir, 'py37_broken')
py37_missing_files_path = os.path.join(env_dir, 'py37_missing_files')
py310_path = os.path.join(env_dir, 'py310')
nopython_path = os.path.join(env_dir, 'nopython')
has_conda_path = os.path.join(env_dir, 'has_conda')
activate_scripts_path = os.path.join(env_dir, 'activate_scripts')
24 changes: 9 additions & 15 deletions conda_pack/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import, print_function, division

import os
import sys
import signal
import tarfile
import time
Expand All @@ -13,9 +12,7 @@
from conda_pack.cli import main
from conda_pack.compat import on_win

from .conftest import py36_path, py27_path

on_p2 = sys.version[0] == '2'
from .conftest import py37_path, py310_path


def test_help(capsys):
Expand Down Expand Up @@ -62,10 +59,10 @@ def capture(**kwargs):


def test_cli_roundtrip(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py36.tar')
out_path = os.path.join(str(tmpdir), 'py37.tar')

with pytest.raises(SystemExit) as exc:
main(["-p", py36_path, "-o", out_path])
main(["-p", py37_path, "-o", out_path])

assert exc.value.code == 0

Expand All @@ -82,10 +79,10 @@ def test_cli_roundtrip(capsys, tmpdir):


def test_quiet(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py36.tar')
out_path = os.path.join(str(tmpdir), 'py37.tar')

with pytest.raises(SystemExit) as exc:
main(["-p", py36_path, "-o", out_path, "-q"])
main(["-p", py37_path, "-o", out_path, "-q"])

assert exc.value.code == 0

Expand Down Expand Up @@ -116,14 +113,12 @@ def test_cli_exceptions(capsys):
assert "usage: conda-pack" in err


@pytest.mark.xfail(on_p2, reason='Relaxing python 2 tests on CI')
def test_cli_warnings(capsys, tmpdir):
out_path = os.path.join(str(tmpdir), 'py27.tar')
out_path = os.path.join(str(tmpdir), 'py310.tar')

with pytest.raises(SystemExit) as exc:
main(["-p", py27_path, "-o", out_path])
main(["-p", py310_path, "-o", out_path])

# Test fails in some CI systems for Python 2
assert exc.value.code == 0

assert os.path.exists(out_path)
Expand All @@ -135,19 +130,18 @@ def test_cli_warnings(capsys, tmpdir):


@pytest.mark.skipif(on_win, reason='SIGINT terminates the tests on Windows')
@pytest.mark.xfail(on_p2, reason='Relaxing python 2 tests on CI')
def test_keyboard_interrupt(capsys, tmpdir):
def interrupt():
time.sleep(0.2)
os.kill(os.getpid(), signal.SIGINT)

interrupter = Thread(target=interrupt)

out_path = os.path.join(str(tmpdir), 'py36.tar')
out_path = os.path.join(str(tmpdir), 'py37.tar')
try:
with pytest.raises(SystemExit) as exc:
interrupter.start()
main(["-p", py36_path, "-o", out_path])
main(["-p", py37_path, "-o", out_path])
except KeyboardInterrupt:
assert False, "Should have been caught by the CLI"

Expand Down
Loading

0 comments on commit 58e2e5e

Please sign in to comment.