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

[tor-commits] [stem/master] Test manual_config_options example



commit 51512eb6627a8b945340d5208fab68eb29885f57
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Sep 29 18:10:28 2020 -0700

    Test manual_config_options example
---
 docs/_static/example/manual_config_options.py |  2 +-
 test/unit/examples.py                         | 25 +++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/docs/_static/example/manual_config_options.py b/docs/_static/example/manual_config_options.py
index 4a503579..336634a3 100644
--- a/docs/_static/example/manual_config_options.py
+++ b/docs/_static/example/manual_config_options.py
@@ -13,7 +13,7 @@ print('Which tor configuration would you like to learn about?  (press ctrl+c to
 
 try:
   while True:
-    requested_option = raw_input('> ').strip()
+    requested_option = input('> ').strip()
 
     if requested_option:
       if requested_option in manual.config_options:
diff --git a/test/unit/examples.py b/test/unit/examples.py
index 12ffb60c..0b4d7082 100644
--- a/test/unit/examples.py
+++ b/test/unit/examples.py
@@ -172,6 +172,21 @@ Circuit 10 (GENERAL)
  +- 65242C91BFF30F165DA4D132C81A9EBA94B71D62 (torexit16, 176.67.169.171)
 """
 
+EXPECTED_MANUAL_CONFIG_OPTIONS = """\
+Downloading tor's manual information, please wait...
+  done
+
+Which tor configuration would you like to learn about?  (press ctrl+c to quit)
+
+IPv6Exit 0|1
+Allow clients to use us for IPv6 traffic
+
+Full Description:
+
+If set, and we are an exit node, allow clients to use us for IPv6 traffic. When this option is set and ExitRelay is auto, we act as if ExitRelay is 1. (Default: 0)
+
+"""
+
 EXPECTED_OUTDATED_RELAYS = """\
 Checking for outdated relays...
 
@@ -704,8 +719,14 @@ class TestExamples(unittest.TestCase):
 
     self.assertEqual(EXPECTED_LIST_CIRCUITS, stdout_mock.getvalue())
 
-  def test_manual_config_options(self):
-    pass
+  @patch('stem.manual.Manual.from_remote', Mock(return_value = stem.manual.Manual.from_cache()))
+  @patch('stem.util.term.format', Mock(side_effect = lambda msg, *args: msg))
+  @patch('sys.stdout', new_callable = io.StringIO)
+  def test_manual_config_options(self, stdout_mock):
+    with patch('builtins.input', Mock(side_effect = ['IPv6Exit', KeyboardInterrupt()])):
+      import manual_config_options
+
+    self.assertEqual(EXPECTED_MANUAL_CONFIG_OPTIONS, stdout_mock.getvalue())
 
   @patch('stem.descriptor.remote.DescriptorDownloader')
   @patch('sys.stdout', new_callable = io.StringIO)



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