RSpecVersion.todict() needs to turn values() into a list()
[sfa.git] / sfa / client / candidates.py
index a49f442..830e24d 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 ### utility to match command-line args to names
 class Candidates:
     def __init__ (self, names):
@@ -9,13 +11,14 @@ class Candidates:
     # returns one of the names if the input name has a unique match
     # or None otherwise
     def only_match (self, input):
+        if input in self.names: return input
         matches=[ name for name in self.names if Candidates.fits(input,name) ]
         if len(matches)==1: return matches[0]
         else: return None
 
 #################### minimal test
 candidates_specs=[
-('create delete reset resources slices start status stop version', 
+('create delete reset resources slices start status stop version create_gid', 
   [ ('ver','version'),
     ('r',None),
     ('re',None),
@@ -28,6 +31,12 @@ candidates_specs=[
     ('sta',None),
     ('stop','stop'),
     ('a',None),
+    ('cre',None),
+    ('create','create'),
+    ('create_','create_gid'),
+    ('create_g','create_gid'),
+    ('create_gi','create_gid'),
+    ('create_gid','create_gid'),
 ])
 ]
 
@@ -36,8 +45,8 @@ def test_candidates ():
         names=names.split()
         for (input,expected) in tuples:
             got=Candidates(names).only_match(input)
-            if got==expected: print '.',
-            else: print 'X FAIL','names[',names,'] input',input,'expected',expected,'got',got
+            if got==expected: print('.', end=' ')
+            else: print('X FAIL','names[',names,'] input',input,'expected',expected,'got',got)
 
 if __name__ == '__main__':
     test_candidates()