Skip to content

Conversation

@tleonhardt
Copy link
Member

Refactored cmd2 code and unit tests so that all usage of the colorama dependency is now limited solely to the ansi.py file.

Added two new functions to ansi.py:

  • async_alert_str()
  • set_title_str()

Also added unit tests for these new functions.

This closes #705

Changes include:
- ansi.py is now the only cmd2 code which depends on colorama
- cmd2 tests no longer rely on colorama
- Added new functions to ansi.py:
    - async_alert_str()
    - set_title_str
- Added unit test for set_title_str

TODO:
- Refactor async_alert_str so cursor position is passed in and import from rl_utils is no longer required
- Add unit test(s) for async_alert_str
- Refactor FG_COLORS and BG_COLORS in ansi.py to not use constants from colorama
…e readline buffer is passed in

This way, the function is independent of readline and can more easily be unit tested
@tleonhardt tleonhardt added this to the 0.9.15 milestone Jul 1, 2019
@tleonhardt tleonhardt requested a review from kmvanbrunt July 1, 2019 04:38
@tleonhardt tleonhardt requested a review from kotfu as a code owner July 1, 2019 04:38
@tleonhardt tleonhardt self-assigned this Jul 1, 2019
@codecov
Copy link

codecov bot commented Jul 1, 2019

Codecov Report

Merging #708 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #708      +/-   ##
==========================================
+ Coverage   95.99%   96.02%   +0.02%     
==========================================
  Files          12       12              
  Lines        3344     3368      +24     
==========================================
+ Hits         3210     3234      +24     
  Misses        134      134
Impacted Files Coverage Δ
cmd2/cmd2.py 96.38% <ø> (-0.01%) ⬇️
cmd2/rl_utils.py 97.43% <ø> (ø) ⬆️
cmd2/ansi.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab64843...ef3eb96. Read the comment docs.

@tleonhardt tleonhardt merged commit 80950bf into master Jul 1, 2019
@tleonhardt tleonhardt deleted the colorama_encapsulation branch July 1, 2019 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encapsulate usage of colorama within ansi.py

3 participants