Move argument checking/manipulation into the front of the function.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@148974 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/functionalities/completion/TestCompletion.py b/test/functionalities/completion/TestCompletion.py
index 481d64f..7906068 100644
--- a/test/functionalities/completion/TestCompletion.py
+++ b/test/functionalities/completion/TestCompletion.py
@@ -93,6 +93,15 @@
     def complete_from_to(self, str_input, patterns):
         """Test that the completion mechanism completes str_input to patterns,
         where patterns could be a pattern-string or a list of pattern-strings"""
+        # Patterns should not be None in order to proceed.
+        self.assertFalse(patterns is None)
+        # And should be either a string or list of strings.  Check for list type
+        # below, if not, make a list out of the singleton string.  If patterns
+        # is not a string or not a list of strings, there'll be runtime errors
+        # later on.
+        if not isinstance(patterns, list):
+            patterns = [patterns]
+        
         # The default lldb prompt.
         prompt = "(lldb) "
 
@@ -127,10 +136,6 @@
                 print "\n\nContents of child_read.txt:"
                 print from_child
 
-            self.assertFalse(patterns is None)
-            if type(patterns) is not types.ListType:
-                patterns = [patterns]
-
             # Test that str_input completes to our patterns.
             # If each pattern matches from_child, the completion mechanism works!
             for p in patterns: