diff --git a/CHANGELOG.md b/CHANGELOG.md index c816e1f..dec20fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - First working version of `dockernel install` and `dockernel start`. [unreleased]: https://github.com/mrmino/dockernel/v1.0.2...HEAD -[1.0.1]: https://github.com/mrmino/dockernel/releases/tag/v1.0.2 +[1.0.2]: https://github.com/mrmino/dockernel/releases/tag/v1.0.2 [1.0.1]: https://github.com/mrmino/dockernel/releases/tag/v1.0.1 [1.0.0]: https://github.com/mrmino/dockernel/releases/tag/v1.0.0 diff --git a/dockernel/cli/install.py b/dockernel/cli/install.py index 488a18e..36f6d6c 100644 --- a/dockernel/cli/install.py +++ b/dockernel/cli/install.py @@ -49,7 +49,7 @@ def python_argv(system_type: str) -> List[str]: def generate_kernelspec_argv(image_name: str, system_type: str) -> List[str]: dockernel_argv = ['dockernel', 'start', - image_name, JUPYTER_CONNECTION_FILE_TEMPLATE] + image_name, JUPYTER_CONNECTION_FILE_TEMPLATE] return python_argv(system_type) + dockernel_argv diff --git a/example_dockerfile b/example_dockerfile index 7dfb2cd..b810b9a 100644 --- a/example_dockerfile +++ b/example_dockerfile @@ -1,4 +1,4 @@ FROM python:3.7-slim-buster RUN pip install --upgrade pip ipython ipykernel -CMD cat $DOCKERNEL_CONNECTION_FILE; python -m ipykernel_launcher -f $DOCKERNEL_CONNECTION_FILE || true +CMD python -m ipykernel_launcher -f $DOCKERNEL_CONNECTION_FILE || true diff --git a/tests/test_install.py b/tests/test_install.py index f5f31f8..424d5cd 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -4,12 +4,13 @@ from dockernel.cli import main_arguments -class TestKernelspecArgvGeneration: +# TODO Add tests for Darwin and Windows +class TestLinuxKernelspecArgvGeneration: IMAGE_NAME = 'example/image-name' @pytest.fixture def argv(self): - return generate_kernelspec_argv(self.IMAGE_NAME) + return generate_kernelspec_argv(self.IMAGE_NAME, 'Linux') def test_argv_starts_with_usr_bin_env_python_m(self, argv): assert argv[:3] == ['/usr/bin/env', 'python', '-m'] diff --git a/tests/test_kernelspec.py b/tests/test_kernelspec.py index 32cba82..354b329 100644 --- a/tests/test_kernelspec.py +++ b/tests/test_kernelspec.py @@ -1,3 +1,4 @@ +import os import pytest import json from dockernel.kernelspec import (Kernelspec, InterruptMode, @@ -7,6 +8,16 @@ from pathlib import Path +@pytest.yield_fixture +def environment_variables(): + starting_state = os.environ.copy() + + yield os.environ + + os.environ.clear() + os.environ.update(starting_state) + + @pytest.fixture def tmpdir(tmpdir): """Workaround for tmpdir being py.path.LocalPath instead of Path""" @@ -81,7 +92,10 @@ def test_raises_ValueError_when_directory_name_is_not_store(self, tmpdir): class TestKernelspecStoreDir: @pytest.mark.parametrize('system_type', ('Linux', 'Windows', 'Darwin')) - def test_works_for_supported_platforms(self, system_type): + def test_works_for_supported_platforms(self, system_type, + environment_variables): + if system_type == 'Windows': + environment_variables['APPDATA'] = '' user_kernelspec_store(system_type) def test_raises_TypeError_on_unknown_system(self):