summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
Commit message (Collapse)AuthorAgeFilesLines
* Updating version and changelog in preparation for minor bug fix realeaseTodd Leonhardt2018-01-041-1/+1
|
* Bump version to 0.7.9aTodd Leonhardt2017-11-151-1/+1
| | | | To distinguish it from the previous or next release
* Added fix for changes in pyperclip project structure in the most recent versionTodd Leonhardt2017-11-081-1/+1
| | | | | | | | | Also included a number of minor maintenance updates: - Bumped version to 0.7.8 in preparation for upcoming release - Updated Readme.md to add link to slides from recent Florida PyCon talk about cmd2 - Updated documentation on integrating cmd2 with other event loops to use newer runcmds_plus_hooks() method instead of legacy onecmds_plus_hooks method which doesn't properly deal with load commands - Deleted old files which were used to prepare for a PyCon 2010 presentation - Updated ChangeLog regarding this bug fix
* Added some unit tests to cover new codeTodd Leonhardt2017-09-231-8/+56
|
* Merge branch 'master' into support-load-in-onecmd_plus_hooksTodd Leonhardt2017-09-221-1/+1
|\
| * Improved documentation for how a user can modify comment grammar/styleTodd Leonhardt2017-09-221-1/+1
| | | | | | | | | | | | | | Also: - Added arg_print.py example to demonstrate this - Bumped version to 0.7.8a - Updated CHANGELOG
* | Provide method to run multiple commands w/o a cmdloop.Alfred Levy2017-09-221-0/+55
|/ | | | | | | | | | | | runcmds_plus_hooks can accept multiple commands process the command queue to deal with subsequent commands loaded from scripts without requiring a command loop. This better supports a one-off batch processing scenario. Also fixed the insertion order of commands placed in the command queue by load and _relative_load so that script commands are run in the expected order. Minor tweak to setup instructions in CONTRIBUTING.md to include pyperclip in prerequisites.
* Improved poutput() so that it can print an integer zero and other falsy thingsTodd Leonhardt2017-09-051-3/+32
| | | | | | | The poutput() function has been ruggedized so that it has a better conditional check so that it will actually print things which are "falsy" but are still convertible to a string. A few unit tests have been added specifically for the poutput function.
* Pick up a few more lines of test coverageJared Crapo2017-08-231-5/+7
|
* Use context managers and decorators for mocksJared Crapo2017-08-231-33/+27
| | | | | | Mocks of six.moves.input() and sys.stdin.isatty() now use either a context manager or a decorator. These wrappers make sure to put the functions back to their unmocked values when the test is done. This change appears to have solved the undeterministic test results.
* Removed unused capsys fixturesJared Crapo2017-08-231-6/+2
|
* Rename tests that exercise pseudo_raw_input()Jared Crapo2017-08-231-12/+12
|
* add tests for pseudo_raw_input when isatty() is trueJared Crapo2017-08-231-0/+42
|
* io.StringIO requires unicode conversion on python2.7Jared Crapo2017-08-231-1/+1
|
* Figured out how to test piped input without hacking stdinJared Crapo2017-08-231-82/+41
|
* Discovered hacking sys.stdin doesn’t always workJared Crapo2017-08-231-17/+75
| | | | When ‘pytest -n8’ parallelizes the test execution, hacking sys.stdin to some other file descriptor yields unpredictable results
* Prompt and line now properly echoed on tty and pipeJared Crapo2017-08-231-1/+50
| | | | if we are on a pipe, we have to echo the prompt only after we read and are not at EOF.
* Improved what gets printed when running commands from a script with load ↵Todd Leonhardt2017-08-231-2/+3
| | | | | | command and echo is True Previously just the command get printed. Now the prompt and the command gets printed.
* Updated CHANGELOG with some text regarding recent enhancements to transcript ↵Todd Leonhardt2017-08-221-1/+1
| | | | | | regexes Also bumped version from 0.7.7a to 0.7.7 in preparation for eventual next release.
* Fixed a unit test which was failing on WindowsTodd Leonhardt2017-08-211-2/+5
| | | | Also fixed a 2nd unrelated unit test which sometimes failed on Windows, depending on what tools were installed or not.
* Converted edit command to an @options command for the better argument ↵Todd Leonhardt2017-08-211-1/+1
| | | | | | parsing related to spaces and quotes The recent change of edit to allow spaces means that it can benefit from the better argument parsing cmd2 has for commands implemented using the @options decorator.
* feedback_to_output now defaults to FalseTodd Leonhardt2017-08-201-3/+7
| | | | This is so that non-essential info which isn't directly associated with command output, such as time elapsed while executing a command, won't redirect when command output is redirected using >, >>, or |.
* Ensure editor and the file to edit can have spaces in themJared Crapo2017-08-191-1/+17
|
* close files opened by mkstempJared Crapo2017-08-191-2/+5
|
* .pfeedback() now honors feedback_to_output settingJared Crapo2017-08-191-21/+57
| | | | If feedback_to_output is false, .pfeedback() now sends messages to stderr instead of stdout.
* Bump versions to 0.7.7aTodd Leonhardt2017-08-151-1/+1
| | | | This is to help distinguish latest code in GitHub from a version installed via pip from PyPI
* Made a few code ruggedizationsTodd Leonhardt2017-08-091-2/+2
| | | | | | - poutput() can now take any argument convertible to a str via '{}'.format() instead of only str - postparsing_postcmd() automatically runs a 'stty sane' on POSIX OSes to handle those cases of your terminal getting in a messed up state if you do something like pipe to a terminal command like "less" and then improperly quit out of it with a <Ctrl>-C instead of properly using "q" - In _restore_output(), immeditelly restore stdout state in a finally block after closing the temporary one used for redirection/piping
* Fixed unit test error on combination of Python 2.7 and WindowsTodd Leonhardt2017-08-071-1/+4
|
* Changed how the pipe file descriptors get opened on Python 3 vs 2Todd Leonhardt2017-08-071-5/+9
| | | | | | | | Open them in text mode in Python 3 so self.stdout.write() expects normal Python 3 (unicode) strings. Open them in binary mode in Python 2 so self.stdout.write() expects normal Python 2 (byte) strings. Also fixed a unit test mocking issue on Python 2 to account for the fact that Python 2.7 requires the subprocess32 module instead of subprocess.
* First attempt at improving how command output gets piped to a shell commandTodd Leonhardt2017-08-071-16/+33
| | | | | | | | | | Now a real pipe is created to a subprocess. This has many advantages and should "just work" like intended with all commands. One downside is to work properly on Python 2.7, it requires the subprocess32 module which is the subprocess module from Python 3.2 backported to Python 2.7. Another downside, is that unit testing the feature is now more difficult. This still needs to be tested for compatibility across all OSes and supported versions of Python. The user needs to be careful if designing multi-threaded cmd2 applications that do command processing in other threads and those threads can make calls to self.stdout.write to put in a try/except to catch Broken Pipe errors which can occur for long running commands if the user closes the shell subprocess before the command is finished.
* Updated CHANGES and bumped version in preparation for 0.7.6 releaseTodd Leonhardt2017-08-021-1/+1
|
* Fixed a unit testTodd Leonhardt2017-07-121-1/+1
| | | | | | Also: - Added a couple unit tests related to case-sensitive vs case-insensitive parsing - Updated CHANGES.md
* Merge pull request #183 from felixonmars/remove-unused-importTodd Leonhardt2017-07-091-2/+0
|\ | | | | Remove unused import in tests
| * Remove unused import in testsFelix Yan2017-07-101-2/+0
| |
* | Use monkeypatch to ensure os.system is restoredFelix Yan2017-07-101-8/+8
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, running tests like test_edit_number before test_default_to_shell_good in the same process will trigger this error: ``` _______________________________________________________________ test_default_to_shell_good ________________________________________________________________ capsys = <_pytest.capture.CaptureFixture object at 0x7f7e90103898> def test_default_to_shell_good(capsys): app = cmd2.Cmd() app.default_to_shell = True line = 'ls' statement = app.parser_manager.parsed(line) retval = app._default(statement) assert not retval out, err = capsys.readouterr() > assert out == '' E AssertionError: assert '*** Unknown syntax: ls \n' == '' E - *** Unknown syntax: ls tests/test_cmd2.py:840: AssertionError ``` Using monkeypatch fixture to restore os.system fixes the problem here.
* Bump version to 0.7.6a (from 0.7.5)Todd Leonhardt2017-07-081-1/+1
|
* Bump version to 0.7.5 (from 0.7.5a)0.7.5Todd Leonhardt2017-07-081-1/+1
|
* Added a unit test for custom intro when calling cmdloop()Todd Leonhardt2017-07-081-4/+4
| | | | Also updated CHANGES.md
* Added a CODEOWNERS file to automatically nominate code reviewers for pull ↵Todd Leonhardt2017-07-081-0/+20
| | | | | | requests Also added some unit tests related to when default_to_shell is True
* Added a few more unit testsTodd Leonhardt2017-07-081-0/+36
|
* Remove ugly file hack code which is no longer necessary as a Python 2/3 ↵Todd Leonhardt2017-07-081-0/+20
| | | | compatibility shim
* Added an eos (end of script) hidden command and load now populates the cmdqueueTodd Leonhardt2017-07-081-26/+48
| | | | | | The load command no longer spawns a nested main loop using _cmdloop(). It now simply adds commands to the cmdqueue. And after adding all commands in the script file, it adds the eos command. The eos command simply pops the most recent script directory from the list of script directories.
* Added unit testTodd Leonhardt2017-07-051-0/+9
|
* Add unit test to verify that exclusion of commands from the history is ↵Todd Leonhardt2017-07-031-0/+44
| | | | working as intended
* Fixed a few bugs and examplesTodd Leonhardt2017-07-031-2/+2
| | | | | | | | | | | | | | Bug fixes: - case_insensitive is no longer a runtime-settable parameter, but it was still listed as such - Fixed a recursive loop bug when abbreviated commands are enabled and it could get stuck in the editor forever - Added additional command abbreviations to the "exclude from history" list - Fixed argparse_example.py and pirate.py examples Other changes: - Organized all attributes used to configure the ParserManager into a single location - Set the default value of "abbrev" to False (which controls whether or not abbreviated commands are allowed) - With good tab-completion of command names, using abbreviated commands isn't a particularly useful feature - And it can create problems
* Bump version to 0.7.5aTodd Leonhardt2017-07-031-1/+1
|
* Removed pause commandTodd Leonhardt2017-07-031-16/+8
| | | | | | It was pretty useless, it just printed a message and sat there and waited for the user to hit enter. It didn't feel like it belonged in a top-level framework. If a particular application wants this functionality, it is a 2 line change to add it back.
* Fixed bugs, removed dead code, and added unit testsTodd Leonhardt2017-07-021-0/+41
| | | | | | | | | | | Fixed a bug where CmdResult named tuple Truthiness wasn't working in Python 2 Removed unused cmd2.History.search() method. Added unit tests for: - History class - cast() function - CmdResult namedtuple
* Added a bunch of unit testsTodd Leonhardt2017-07-021-12/+167
| | | | Also improved error handling in some exceptional cases.
* shell command now uses cmd.Cmd.stdout for outputTodd Leonhardt2017-07-021-3/+1
| | | | | | | | | The main advantages of this are that shell command output can now be - piped to another shell command - redirected to a file In the future, I may take it a step further where the output is piped, but using a pipe versus a real terminal changes the behavior of many shell commands, for example by getting rid of ANSI color and various other pretty formatting.