* [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/, /
@ 2015-08-05 21:32 Michał Górny
0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2015-08-05 21:32 UTC (permalink / raw
To: gentoo-commits
commit: 1b0b008f8f3bacb160d89745e18b1419d496c2cf
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 5 21:23:42 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug 5 21:23:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/gentoopm.git/commit/?id=1b0b008f
Add tests for BashServer
gentoopm/tests/bash.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
setup.py | 4 ++++
2 files changed, 54 insertions(+)
diff --git a/gentoopm/tests/bash.py b/gentoopm/tests/bash.py
new file mode 100644
index 0000000..4e7d5a0
--- /dev/null
+++ b/gentoopm/tests/bash.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+# vim:fileencoding=utf-8
+# (c) 2015 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+import io
+import unittest
+
+from gentoopm.bash.bashserver import BashServer
+
+class BashServerTestCase(unittest.TestCase):
+ basic_data = b'''
+VAR1=test
+VAR2="test test"
+export VAR3=test
+declare VAR4=test
+'''
+
+ def setUp(self):
+ self._bash_server = BashServer()
+
+ def tearDown(self):
+ del self._bash_server
+
+ def test_getitem(self):
+ self._bash_server.load_file(io.BytesIO(self.basic_data))
+ self.assertEqual(self._bash_server['VAR1'], 'test')
+ self.assertEqual(self._bash_server['VAR2'], 'test test')
+ self.assertEqual(self._bash_server['VAR3'], 'test')
+ self.assertEqual(self._bash_server['VAR4'], 'test')
+
+ def test_copy(self):
+ self._bash_server.load_file(io.BytesIO(self.basic_data))
+ out = self._bash_server.copy('VAR1', 'VAR2', 'VAR3', 'VAR4')
+ self.assertEqual(out, {
+ 'VAR1': 'test',
+ 'VAR2': 'test test',
+ 'VAR3': 'test',
+ 'VAR4': 'test',
+ })
+
+ def test_random_output(self):
+ ''' Test if random output is discarded correctly. '''
+ data = io.BytesIO(b'''
+echo FOO
+echo BAR >&2
+TEST=test
+''')
+ self._bash_server.load_file(data)
+ self.assertEqual(self._bash_server['TEST'], 'test')
diff --git a/setup.py b/setup.py
index 8f987a4..aee2e81 100755
--- a/setup.py
+++ b/setup.py
@@ -55,6 +55,10 @@ class TestCommand(Command):
maintestsuite = unittest.TestSuite()
+ # common tests
+ commonloader = gentoopm.tests.PMTestLoader(None)
+ maintestsuite.addTests(commonloader.loadTestsFromModule('gentoopm.tests.bash'))
+
for pm in gentoopm.submodules._supported_pms:
try:
pm_inst = gentoopm.submodules.get_pm(pm)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-05 21:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 21:32 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/, / Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox