summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gd_diff.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index 650094f..2d6fe86 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -7,12 +7,14 @@
# <https://creativecommons.org/publicdomain/zero/1.0>
import os
+import subprocess
import sys
from nose.tools import *
from gd_diff import *
+
class TestGdDiff(object):
def setup(self):
@@ -32,6 +34,29 @@ class TestGdDiff(object):
f_content = read_file(self.pkgs_file_ne)
+ def test_execute_success(self):
+ cmd = 'python --version'
+ cp = execute(cmd, out=subprocess.PIPE)
+
+ assert cp.returncode == 0
+ assert cp.stdout.split()[0] == b'Python'
+ assert cp.stdout.split()[1].startswith(b'3.5')
+
+ def test_execute_cmderror(self):
+ cmd = 'bzr cat bzr://bzr.sv.gnu.org/gnewsense/packages-parkes/nonexistent-packages/debian/README.gNewSense'
+ cp = execute(cmd, err=subprocess.PIPE)
+
+ assert cp.returncode == 3
+ assert cp.stderr.startswith(b'bzr: ERROR:')
+
+
+ @raises(SystemExit)
+ def test_execute_raise_exception(self):
+ cmd = 'cornhole computers'
+ with open(os.devnull, 'w') as sys.stderr:
+ cp = execute(cmd)
+
+
def test_get_packages(self):
pkgs_iter = get_packages(self.pkgs_file)
assert len(list(pkgs_iter)) == 82