This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
catfish/tests/test_project/test_cli.py

30 lines
1.1 KiB
Python

from io import StringIO
from dotenv import dotenv_values
from catfish.project import Project
from tests import BaseTestCase
class ProjectRunCLITestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.project = Project(self.EXAMPLE_DIR)
def test_sets_environment(self):
with self.in_example_dir():
result = self.run_cli(["project", "run", "env"], catch_exceptions=False)
self.assertEqual(result.exit_code, 0)
env = dotenv_values(stream=StringIO(result.stdout))
self.assertEqual(env["FOO"], "bar")
self.assertEqual(env["PYTHONUNBUFFERED"], "1")
self.assertIsNone(env.get("CATFISH_IDENT"))
self.assertIn(str(self.project.root), env["PATH"])
for path in self.project.get_extra_path():
self.assertIn(str(path), env["PATH"])
def test_sets_working_dir(self):
with self.in_example_dir():
result = self.run_cli(["project", "run", "pwd"], catch_exceptions=False)
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.stdout.strip(), str(self.project.root))