[tor-commits] [stem/master] Move hello_world test

atagar at torproject.org atagar at torproject.org
Fri Oct 2 23:16:05 UTC 2020


commit 21ce92eda4855e8091b163713e8f8ed00b4181ef
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Sep 27 16:06:45 2020 -0700

    Move hello_world test
---
 test/unit/examples.py | 14 ++++++++++++--
 test/unit/tutorial.py | 12 ------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/unit/examples.py b/test/unit/examples.py
index 3f528b80..9250280e 100644
--- a/test/unit/examples.py
+++ b/test/unit/examples.py
@@ -438,8 +438,18 @@ class TestExamples(unittest.TestCase):
   def test_get_hidden_service_descriptor(self):
     pass
 
-  def test_hello_world(self):
-    pass
+  @patch('stem.control.Controller.from_port', spec = Controller)
+  @patch('sys.stdout', new_callable = io.StringIO)
+  def test_hello_world(self, stdout_mock, from_port_mock):
+    controller = from_port_mock().__enter__()
+    controller.get_info.side_effect = lambda arg: {
+      'traffic/read': '33406',
+      'traffic/written': '29649',
+    }[arg]
+
+    import hello_world
+
+    self.assertEqual('My Tor relay has read 33406 bytes and written 29649.\n', stdout_mock.getvalue())
 
   def test_introduction_points(self):
     pass
diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py
index 140bbba5..92793afe 100644
--- a/test/unit/tutorial.py
+++ b/test/unit/tutorial.py
@@ -46,18 +46,6 @@ class TestTutorial(unittest.TestCase):
 
     stem.descriptor.remote.SINGLETON_DOWNLOADER = None
 
-  @patch('sys.stdout', new_callable = io.StringIO)
-  @patch('stem.control.Controller.from_port', spec = Controller)
-  def test_the_little_relay_that_could(self, from_port_mock, stdout_mock):
-    controller = from_port_mock().__enter__()
-    controller.get_info.side_effect = lambda arg: {
-      'traffic/read': '33406',
-      'traffic/written': '29649',
-    }[arg]
-
-    exec_documentation_example('hello_world.py')
-    self.assertEqual('My Tor relay has read 33406 bytes and written 29649.\n', stdout_mock.getvalue())
-
   @patch('sys.stdout', new_callable = io.StringIO)
   @patch('shutil.rmtree')
   @patch('stem.control.Controller.from_port', spec = Controller)





More information about the tor-commits mailing list