Skip to content

Commit

Permalink
relative to root_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Jan 20, 2024
1 parent f0f427d commit e0c1ba4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/test_conda_subprocess.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
from unittest import TestCase
import os
from subprocess import PIPE
from unittest import TestCase

from conda.base.context import context
from conda_subprocess import call, check_call, check_output, run, Popen


class TestCondaSubprocess(TestCase):
def setUp(self):
self.env_path = os.path.join(context.root_prefix, "..", "py312")

def test_call(self):
self.assertEqual(call("python --version", prefix_path="../py312"), 0)
self.assertEqual(call("python --version", prefix_path=self.env_path), 0)

def test_check_call(self):
self.assertEqual(check_call("python --version", prefix_path="../py312"), 0)
self.assertEqual(check_call("python --version", prefix_path=self.env_path), 0)

def test_check_output(self):
self.assertEqual(check_output("python --version", prefix_path="../py312"), b'Python 3.12.1\n')
self.assertEqual(check_output("python --version", prefix_path=self.env_path), b'Python 3.12.1\n')

def test_check_output_universal_newlines(self):
self.assertEqual(check_output("python --version", prefix_path="../py312", universal_newlines=True), 'Python 3.12.1\n')
self.assertEqual(check_output("python --version", prefix_path=self.env_path, universal_newlines=True), 'Python 3.12.1\n')

def test_run(self):
self.assertEqual(run("python --version", prefix_path="../py312").returncode, 0)
self.assertEqual(run("python --version", prefix_path=self.env_path).returncode, 0)

def test_popen(self):
process = Popen("python --version", prefix_path="../py312", stdout=PIPE)
process = Popen("python --version", prefix_path=self.env_path, stdout=PIPE)
output = process.communicate()
self.assertEqual(output[0], b'Python 3.12.1\n')
self.assertIsNone(output[1])

0 comments on commit e0c1ba4

Please sign in to comment.