Skip to content
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

History fix when when file is empty. #109

Merged
merged 3 commits into from
Oct 9, 2021

Conversation

rpesche
Copy link
Contributor

@rpesche rpesche commented Oct 6, 2021

This PR fix #108

I also add some test using pytest.
In order to more easily test show_history I made a little refactoring, spliting it into two method show_history and get_history_record.

I know the contributing guide say we must make single bug per PR, but I'm used to work in TDD, and there is no tests in mitype.

Romain Pesche added 2 commits October 6, 2021 22:55
The history file, located in `~/.mitype_history.csv` must contain csv data
holding all user typing history.

If this file is empty, without csv header, a `StopIteration` is raised,
crashing `mitype`.

This commit fix this exception and print a string, showing no records
found.

This fixes bug Mithil467#108
The `show_history` method aim to print history logs of the users.
It has a single `number_record` parameter used to select the number of
record to print.

The major part of this function is used to extract the log data from the
`.mitype_history.csv` csv file. The other part is used to print this
extract.

This commit separate this two features in order to clean the code and
ease testing.
@Mithil467
Copy link
Owner

Thanks @rpesche for the issue!
Appreciate your interest in contributing to the project. Thanks for working on it.

Copy link
Owner

@Mithil467 Mithil467 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate the unit tests.
Thanks for your contribution! 🙌🏼

@Mithil467 Mithil467 merged commit 1b9c1cc into Mithil467:master Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mitype crash when the ~/.mitype_history.csv exists without header
2 participants