-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0f427d
commit e0c1ba4
Showing
1 changed file
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |