From 35afe726c195c18ec056612d4688da8a496164ea Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Fri, 1 Aug 2008 19:29:38 -0700
Subject: [PATCH] test_cli.py: factor out CLITestMixin

---
 src/allmydata/test/test_cli.py | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py
index fb59478b..d7a62e84 100644
--- a/src/allmydata/test/test_cli.py
+++ b/src/allmydata/test/test_cli.py
@@ -217,8 +217,7 @@ class CLI(unittest.TestCase):
         self.failUnless("storage index: nt4fwemuw7flestsezvo2eveke" in output, output)
         self.failUnless("fingerprint: 737p57x6737p57x6737p57x6737p57x6737p57x6737p57x6737a" in output, output)
 
-class CreateAlias(SystemTestMixin, unittest.TestCase):
-
+class CLITestMixin:
     def do_cli(self, verb, *args, **kwargs):
         nodeargs = [
             "--node-directory", self.getdir("client0"),
@@ -234,6 +233,8 @@ class CreateAlias(SystemTestMixin, unittest.TestCase):
         d.addCallback(_done)
         return d
 
+class CreateAlias(SystemTestMixin, CLITestMixin, unittest.TestCase):
+
     def test_create(self):
         self.basedir = os.path.dirname(self.mktemp())
         d = self.set_up_nodes()
@@ -247,22 +248,7 @@ class CreateAlias(SystemTestMixin, unittest.TestCase):
         d.addCallback(_done)
         return d
 
-class Put(SystemTestMixin, unittest.TestCase):
-
-    def do_cli(self, verb, *args, **kwargs):
-        nodeargs = [
-            "--node-directory", self.getdir("client0"),
-            ]
-        argv = [verb] + nodeargs + list(args)
-        stdin = kwargs.get("stdin", "")
-        stdout, stderr = StringIO(), StringIO()
-        d = threads.deferToThread(runner.runner, argv, run_by_human=False,
-                                  stdin=StringIO(stdin),
-                                  stdout=stdout, stderr=stderr)
-        def _done(res):
-            return stdout.getvalue(), stderr.getvalue()
-        d.addCallback(_done)
-        return d
+class Put(SystemTestMixin, CLITestMixin, unittest.TestCase):
 
     def test_unlinked_immutable_stdin(self):
         # tahoe get `echo DATA | tahoe put`
-- 
2.45.2