test\conftest.py
-- -- --- --- --- --- --- --- ------- ------- ------- | import pathlib
-- -- --- --- --- --- --- --- ------- ------- ------- | import shutil
-- -- --- --- --- --- --- --- ------- ------- ------- | import tempfile
-- -- --- --- --- --- --- --- ------- ------- ------- | from textwrap import dedent
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | import pytest
-- -- --- --- --- --- --- --- ------- ------- ------- | from click.testing import CliRunner
-- -- --- --- --- --- --- --- ------- ------- ------- | from git.repo.base import Repo
-- -- --- --- --- --- --- --- ------- ------- ------- | from git.util import Actor
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | import wily.__main__ as main
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.fixture
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | def gitdir(tmpdir):
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | """Create a project and add code to it"""
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | repo = Repo.init(path=tmpdir)
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | tmppath = pathlib.Path(tmpdir)
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | testpath = tmppath / "src" / "test.py"
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | (tmppath / "src").mkdir()
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | # Write a test file to the repo
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | with open(testpath, "w") as test_txt:
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | test_txt.write("import abc")
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index = repo.index
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.add([str(testpath)])
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author = Actor("An author", "author@example.com")
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | committer = Actor("A committer", "committer@example.com")
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.commit(
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | "basic test",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author=author,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | committer=committer,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author_date="Thu, 07 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | commit_date="Thu, 07 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | )
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | first_test = """
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | import abc
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | foo = 1
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | def function1():
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | a = 1 + 1
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | class Class1(object):
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | def method(self):
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | b = 1 + 5
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | """
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | with open(testpath, "w") as test_txt:
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | test_txt.write(dedent(first_test))
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.add([str(testpath)])
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.commit(
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | "add line",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author=author,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | committer=committer,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author_date="Mon, 10 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | commit_date="Mon, 10 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | )
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | second_test = """
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | import abc
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | foo = 1
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | def function1():
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | a = 1 + 1
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | class Class1(object):
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | def method(self):
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | b = 1 + 5
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | if b == 6:
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | return 'banana'
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | """
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | with open(testpath, "w") as test_txt:
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | test_txt.write(dedent(second_test))
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.add([str(testpath)])
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | index.commit(
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | "remove line",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author=author,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | committer=committer,
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | author_date="Thu, 14 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | commit_date="Thu, 14 Apr 2019 22:13:13 +0200",
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | )
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 |
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | yield tmpdir
-- 01 001 004 003 006 005 009 0020.90 0015.67 0000.75 | repo.close()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.fixture
-- 01 002 004 004 008 006 012 0031.02 0062.04 0002.00 | def builddir(gitdir):
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | """
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | A directory with a wily cache
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | """
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | tmppath = pathlib.Path(gitdir)
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | runner = CliRunner()
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | result1 = runner.invoke(
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | main.cli, ["--debug", "--path", gitdir, "build", str(tmppath / "src")]
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | )
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | assert result1.exit_code == 0, result1.stdout
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 |
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | result2 = runner.invoke(main.cli, ["--debug", "--path", gitdir, "index"])
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | assert result2.exit_code == 0, result2.stdout
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 |
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | yield gitdir
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 |
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | result1 = runner.invoke(main.cli, ["--debug", "--path", gitdir, "clean", "-y"])
-- -- 002 004 004 008 006 012 0031.02 0062.04 0002.00 | assert result1.exit_code == 0, result1.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.fixture
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | def ipynbgitdir(tmpdir):
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | A fixture that provides a directory and a working Git DB,
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | contains a single IPython notebook that has 3 revisions.
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | _NB_FOOTER = """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "metadata": {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "kernelspec": {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "display_name": "Python 3",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "language": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "name": "python3"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | },
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "language_info": {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "codemirror_mode": {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "name": "ipython",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "version": 3
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | },
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "file_extension": ".py",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "mimetype": "text/x-python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "name": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "nbconvert_exporter": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "pygments_lexer": "ipython3",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "version": "3.4.2"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | }
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | },
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "nbformat": 4,
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "nbformat_minor": 0
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | repo = Repo.init(path=tmpdir)
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | tmppath = pathlib.Path(tmpdir)
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | testpath = tmppath / "src" / "test.ipynb"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | (tmppath / "src").mkdir()
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | # Write a test file to the repo
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | with open(testpath, "w") as test_txt:
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | test_txt.write('{"cells": [],' + _NB_FOOTER + "}")
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index = repo.index
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.add([str(testpath)])
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | author = Actor("An author", "author@example.com")
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | committer = Actor("A committer", "committer@example.com")
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.commit("empty notebook", author=author, committer=committer)
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | first_test = (
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """{
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "cells": [
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "cell_type": "code",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "metadata": {},
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "language": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "source": [
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "import abc\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "foo = 1\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "def function1():\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " a = 1 + 1\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "class Class1(object):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " def method(self):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " b = 1 + 5\\n"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | ],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "outputs": [],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "execution_count": 0,
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "input": []
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | }
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | ],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | + _NB_FOOTER
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | + "}"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | )
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | with open(testpath, "w") as test_txt:
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | test_txt.write(dedent(first_test))
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.add([str(testpath)])
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.commit("single cell", author=author, committer=committer)
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | second_test = (
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """{
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "cells": [
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "cell_type": "code",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "metadata": {},
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "language": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "source": [
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "import abc\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "foo = 1\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "def function1():\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " a = 1 + 1\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "class Class1(object):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " def method(self):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " b = 1 + 5\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " if b == 6:\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " return 'banana'\\n"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | ],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "outputs": [],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "execution_count": 0,
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "input": []
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | },
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | {
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "cell_type": "code",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "metadata": {},
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "language": "python",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "source": [
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "foo = 1\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "class Class1(object):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " def method(self):\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " b = 1 + 5\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " if b == 6:\\n",
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | " return 'banana'\\n"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | ],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "outputs": [],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "execution_count": 0,
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | "input": []
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | }
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | ],
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | """
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | + _NB_FOOTER
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | + "}"
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | )
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | with open(testpath, "w") as test_txt:
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | test_txt.write(dedent(second_test))
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.add([str(testpath)])
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | index.commit("second cell", author=author, committer=committer)
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 |
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | yield tmpdir
-- 01 002 012 009 018 014 027 0102.80 0154.20 0001.50 | repo.close()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.fixture
-- 01 002 005 005 010 007 015 0042.11 0084.22 0002.00 | def ipynbbuilddir(ipynbgitdir):
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | """
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | The ipynbgitdir fixture converted into a wily cache index.
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | """
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | tmppath = pathlib.Path(ipynbgitdir)
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 |
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | config = """
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | [wily]
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | include_ipynb = true
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | ipynb_cells = true
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | """
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | config_path = tmppath / "wily.cfg"
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | with open(config_path, "w") as config_f:
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | config_f.write(config)
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 |
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | runner = CliRunner()
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | result1 = runner.invoke(
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | main.cli, ["--debug", "--path", ipynbgitdir, "build", str(tmppath / "src")]
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | )
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | assert result1.exit_code == 0, result1.stdout
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 |
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | result2 = runner.invoke(main.cli, ["--debug", "--path", ipynbgitdir, "index"])
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | assert result2.exit_code == 0, result2.stdout
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 |
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | yield ipynbgitdir
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 |
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | result1 = runner.invoke(main.cli, ["--debug", "--path", ipynbgitdir, "clean", "-y"])
-- -- 002 005 005 010 007 015 0042.11 0084.22 0002.00 | assert result1.exit_code == 0, result1.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.fixture(autouse=True)
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | def cache_path(monkeypatch):
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | Configure wily cache and home path, clean up cache afterward
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | """
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | tmp = tempfile.mkdtemp()
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | monkeypatch.setenv("HOME", tmp)
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | yield tmp
-- 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 | shutil.rmtree(tmp)