[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 21ce92eda4855e8091b163713e8f8ed00b4181ef
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits