python - How can I feed keys in to a terminal for unittesting purposes -


i'm working on plug-in vim, , i'd test behaves correctly, under start-up, when users edit files e.t.c.

to this, i'd start terminal, , feed keys in it. i'm thinking of doing python script. there way this?

in pseudo-python might this:

#start terminal. here konsole konsole = os.system('konsole --width=200 --height=150')  #start vim in terminal konsole.feed_keys("vim\n") #run vim function tested konsole.feed_keys(":let my_list = myvimfunction()\n") #save return value file system konsole.feed_keys(":writefile(my_list, '/tmp/result')\n")  #load result python open('/tmp/result', 'r') myfile:     data = myfile.read()  #validate result assertequal('expect result', data) 

i think should verify core functionality of plugin inside vim, using unit tests. there's wide variety of vim plugins, provide additional mappings or commands, invoked user, , leave behind side effects in buffer, or output, or opened windows. can verified inside vim. there various approaches that, mine runvimtests test framework; plugin page has links several alternatives.

with core functionality covered, there's little left test "interactively". (i mean stuff forgotten debug output, long execution times, display mess-ups.) since you're heavy user of vim , plugin yourself, covers it.


of course, if plugin embeds tightly vim (like "ide xxx"; though frowned upon), may consider external test driver. maybe others contribute pointers general-purpose, terminal-driven test frameworks. i'm sure such exist.


Comments

Popular posts from this blog

javascript - Uncaught FirebaseError: Messaging: This method is available in a Window context -

c# - How to clear picker if It is selected in xamarin forms? -

angular - File Name and Extension not respected when sent from .NET Web API to Angular2 App -