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

[tor-commits] [stem/master] Tests requiring man command can't work on bsd



commit 336a2a8680964db55610cd63b7b0dc292dfc71d1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Sep 4 13:24:15 2017 -0700

    Tests requiring man command can't work on bsd
    
    Several tests skipped on OSX need to also be skipped on BSD. There were also
    some other newer tests that probably aren't running on OSX.
    
      ======================================================================
      ERROR: test_saving_manual_as_config
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/tmp/stem/test/require.py", line 58, in wrapped
          return func(self, *args, **kwargs)
        File "/tmp/stem/test/unit/manual.py", line 205, in test_saving_manual_as_config
          manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
        File "/tmp/stem/stem/manual.py", line 495, in from_man
          categories, config_options = _get_categories(man_output), OrderedDict()
        File "/tmp/stem/stem/manual.py", line 666, in _get_categories
          if lines[-1] == '':
      IndexError: list index out of range
    
      ----------------------------------------------------------------------
---
 stem/manual.py      |  2 +-
 test/unit/manual.py | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/stem/manual.py b/stem/manual.py
index 6e4869cf..3440b36d 100644
--- a/stem/manual.py
+++ b/stem/manual.py
@@ -663,7 +663,7 @@ def _get_categories(content):
 
     if line and not line.startswith(' '):
       if category:
-        if lines[-1] == '':
+        if lines and lines[-1] == '':
           lines = lines[:-1]  # sections end with an extra empty line
 
         categories[category] = lines
diff --git a/test/unit/manual.py b/test/unit/manual.py
index b7e0adfc..70e28aaf 100644
--- a/test/unit/manual.py
+++ b/test/unit/manual.py
@@ -153,8 +153,8 @@ class TestManual(unittest.TestCase):
     expand our example (or add another).
     """
 
-    if stem.util.system.is_mac():
-      self.skipTest('(man lacks --encoding arg on OSX, #18660)')
+    if stem.util.system.is_mac() or stem.util.system.is_bsd():
+      self.skipTest('(man lacks --encoding arg on OSX and BSD, #18660)')
       return
 
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
@@ -174,8 +174,8 @@ class TestManual(unittest.TestCase):
     options. Unlike most other tests this doesn't require network access.
     """
 
-    if stem.util.system.is_mac():
-      self.skipTest('(man lacks --encoding arg on OSX, #18660)')
+    if stem.util.system.is_mac() or stem.util.system.is_bsd():
+      self.skipTest('(man lacks --encoding arg on OSX and BSD, #18660)')
       return
 
     manual = stem.manual.Manual.from_man(UNKNOWN_OPTIONS_MAN_PATH)
@@ -202,6 +202,10 @@ class TestManual(unittest.TestCase):
     Check that we can save and reload manuals as a config.
     """
 
+    if stem.util.system.is_mac() or stem.util.system.is_bsd():
+      self.skipTest('(man lacks --encoding arg on OSX and BSD, #18660)')
+      return
+
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
 
     with tempfile.NamedTemporaryFile(prefix = 'saved_test_manual.') as tmp:
@@ -209,11 +213,16 @@ class TestManual(unittest.TestCase):
       loaded_manual = stem.manual.Manual.from_cache(tmp.name)
       self.assertEqual(manual, loaded_manual)
 
+  @test.require.command('man')
   def test_saving_manual_as_sqlite(self):
     """
     Check that we can save and reload manuals as sqlite.
     """
 
+    if stem.util.system.is_mac() or stem.util.system.is_bsd():
+      self.skipTest('(man lacks --encoding arg on OSX and BSD, #18660)')
+      return
+
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
 
     with tempfile.NamedTemporaryFile(prefix = 'saved_test_manual.', suffix = '.sqlite') as tmp:

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