From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/tests/, /
Date: Wed, 5 Aug 2015 21:32:15 +0000 (UTC) [thread overview]
Message-ID: <1438809822.1b0b008f8f3bacb160d89745e18b1419d496c2cf.mgorny@gentoo> (raw)
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)
reply other threads:[~2015-08-05 21:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438809822.1b0b008f8f3bacb160d89745e18b1419d496c2cf.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox