mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Try passing a directory to isolated_filesystem(), refs #1406
This commit is contained in:
parent
74b775e20f
commit
e55cd9dc3f
3 changed files with 34 additions and 40 deletions
|
|
@ -2,7 +2,6 @@ from click.testing import CliRunner
|
|||
from datasette import cli
|
||||
from unittest import mock
|
||||
import pathlib
|
||||
import pytest
|
||||
|
||||
|
||||
class CaptureDockerfile:
|
||||
|
|
@ -24,15 +23,14 @@ CMD datasette serve --host 0.0.0.0 -i test.db --cors --inspect-file inspect-data
|
|||
""".strip()
|
||||
|
||||
|
||||
@pytest.mark.serial
|
||||
@mock.patch("shutil.which")
|
||||
@mock.patch("datasette.cli.call")
|
||||
def test_package(mock_call, mock_which):
|
||||
def test_package(mock_call, mock_which, tmp_path_factory):
|
||||
mock_which.return_value = True
|
||||
runner = CliRunner()
|
||||
capture = CaptureDockerfile()
|
||||
mock_call.side_effect = capture
|
||||
with runner.isolated_filesystem():
|
||||
with runner.isolated_filesystem(tmp_path_factory.mktemp("runner")):
|
||||
with open("test.db", "w") as fp:
|
||||
fp.write("data")
|
||||
result = runner.invoke(cli.cli, ["package", "test.db", "--secret", "sekrit"])
|
||||
|
|
@ -43,12 +41,12 @@ def test_package(mock_call, mock_which):
|
|||
|
||||
@mock.patch("shutil.which")
|
||||
@mock.patch("datasette.cli.call")
|
||||
def test_package_with_port(mock_call, mock_which):
|
||||
def test_package_with_port(mock_call, mock_which, tmp_path_factory):
|
||||
mock_which.return_value = True
|
||||
capture = CaptureDockerfile()
|
||||
mock_call.side_effect = capture
|
||||
runner = CliRunner()
|
||||
with runner.isolated_filesystem():
|
||||
with runner.isolated_filesystem(tmp_path_factory.mktemp("runner")):
|
||||
with open("test.db", "w") as fp:
|
||||
fp.write("data")
|
||||
result = runner.invoke(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue