-
Notifications
You must be signed in to change notification settings - Fork 124
Added optional persistent readline history feature #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Including an example and info in the Sphinx docs Also: - Created CHANGELOG entry for 0.8.1 release - Added info to README about new sub-menu feature - Bumped version to 0.8.1 TODO: - Added a unit test for the persistent readline history feature
|
@kotfu I can't figure out a good way to unit test readline history behavior to unit test this new persistent history feature. I manually tested it and verified it works on Windows, Mac, and Linux as well as Python 2 and 3. But I would prefer to have a unit test. Can you think of any way to unit test this? |
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
==========================================
- Coverage 92.07% 91.56% -0.52%
==========================================
Files 1 1
Lines 1413 1422 +9
==========================================
+ Hits 1301 1302 +1
- Misses 112 120 +8
Continue to review full report at Codecov.
|
Added pexpect to modules required for running unit tests. This opens the door for carefully crafted complex unit tests to verify intricate behavior. Tests like this are somewhat painful to write and slow to execute. However, they can enable testing complicated interactive behavior that we otherwise probably would not be able to test.
|
So the pexpect-based unit test works fine on my computer and I tested on both macOS and Linux. However, it doesn't work on TravisCI. |
…ing different there
…acOS - The Windows pexpect API is different from macOS or Linux - On Travis CI, the test behaves as if readline isn't working on those machines - The test runs fine when run on my system (on either macOS or Linux)
Added two additional optional parameters to the
cmd2.Cmdclass init():If persistent_history_file is supplied and is non-empty, then at the beginning of its initialization, the
cmd2.Cmdclass attempts to expand this path and load readline history from this file. If the file isn't found, it just moves on. It also uses atexit to register saving the readline history to this file when thecmd2application exits.The persistent_history_file argument defaults to an empty string and thus by default the
cmd2.Cmdapplication does NOT use a persistent readline history.Included an example and info in the Sphinx docs.
Unrelated changes added to this PR:
This closes #265.