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

[tor-commits] [stem/master] Show manual differnces in integ test



commit e506b0c7612fea030eb7973d622a37d5073ab172
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Dec 5 16:21:47 2015 -0800

    Show manual differnces in integ test
    
    When our cached manual is out of date our test simply says 'they're different'.
    Lovely, but lot better to give something more useful. ;)
---
 cache_manual.py      |   23 +----------------------
 stem/manual.py       |   32 ++++++++++++++++++++++++++++++++
 test/integ/manual.py |    2 +-
 3 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/cache_manual.py b/cache_manual.py
index 24d8bb7..eedb1ed 100755
--- a/cache_manual.py
+++ b/cache_manual.py
@@ -49,28 +49,7 @@ if __name__ == '__main__':
     sys.exit(0)
 
   print('Differences detected...\n')
-
-  for attr in ('name', 'synopsis', 'description', 'commandline_options', 'signals', 'files', 'config_options'):
-    cached_attr = getattr(cached_manual, attr)
-    latest_attr = getattr(latest_manual, attr)
-
-    if cached_attr != latest_attr:
-      print("* Manual's %s attribute changed\n" % attr)
-
-      if attr in ('name', 'synopsis', 'description'):
-        print('  Previously...\n\n%s\n' % cached_attr)
-        print('  Updating to...\n\n%s' % latest_attr)
-      else:
-        added_items = set(latest_attr.items()).difference(cached_attr.items())
-        removed_items = set(cached_attr.items()).difference(latest_attr.items())
-
-        for added_item in added_items:
-          print('  adding %s => %s' % added_item)
-
-        for removed_item in removed_items:
-          print('  removing %s => %s' % removed_item)
-
-      print('\n')
+  print(stem.manual._manual_differences(cached_manual, latest_manual))
 
   latest_manual.man_commit = man_commit
   latest_manual.stem_commit = stem_commit
diff --git a/stem/manual.py b/stem/manual.py
index c55d72c..24ec447 100644
--- a/stem/manual.py
+++ b/stem/manual.py
@@ -130,6 +130,38 @@ def _config(lowercase = True):
     return {}
 
 
+def _manual_differences(previous_manual, new_manual):
+  """
+  Provides a description of how two manuals differ.
+  """
+
+  lines = []
+
+  for attr in ('name', 'synopsis', 'description', 'commandline_options', 'signals', 'files', 'config_options'):
+    previous_attr = getattr(previous_manual, attr)
+    new_attr = getattr(new_manual, attr)
+
+    if previous_attr != new_attr:
+      lines.append("* Manual's %s attribute changed\n" % attr)
+
+      if attr in ('name', 'synopsis', 'description'):
+        lines.append('  Previously...\n\n%s\n' % previous_attr)
+        lines.append('  Updating to...\n\n%s' % new_attr)
+      else:
+        added_items = set(new_attr.items()).difference(previous_attr.items())
+        removed_items = set(previous_attr.items()).difference(new_attr.items())
+
+        for added_item in added_items:
+          lines.append('  adding %s => %s' % added_item)
+
+        for removed_item in removed_items:
+          lines.append('  removing %s => %s' % removed_item)
+
+      lines.append('\n')
+
+  return '\n'.join(lines)
+
+
 def is_important(option):
   """
   Indicates if a configuration option of particularly common importance or not.
diff --git a/test/integ/manual.py b/test/integ/manual.py
index 573ee2f..c961101 100644
--- a/test/integ/manual.py
+++ b/test/integ/manual.py
@@ -199,7 +199,7 @@ class TestManual(unittest.TestCase):
     latest_manual = stem.manual.Manual.from_man(self.man_path)
 
     if cached_manual != latest_manual:
-      self.fail("Stem's cached manual information is out of date. Please run 'cache_manual.py'.")
+      self.fail("Stem's cached manual information is out of date. Please run 'cache_manual.py'...\n\n%s" % stem.manual._manual_differences(cached_manual, latest_manual))
 
   def test_attributes(self):
     """



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