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

Improve primelib.py test coverage #9943 #10251

Merged
merged 9 commits into from
Oct 11, 2023

Conversation

rmp2000
Copy link
Contributor

@rmp2000 rmp2000 commented Oct 10, 2023

Describe your change:

Improve the doctest in the primelib.py file.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed labels Oct 10, 2023
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 10, 2023
Comment on lines 731 to 738
(1,2)
>>> simplify_fraction(10,-1)
Traceback (most recent call last):
...
AssertionError: The arguments must been from type int and 'denominator' != 0"
>>> simplify_fraction("test","test")
Traceback (most recent call last):
...
Copy link
Member

@cclauss cclauss Oct 10, 2023

Choose a reason for hiding this comment

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

Doctests are very literal.

Suggested change
(1,2)
>>> simplify_fraction(10,-1)
Traceback (most recent call last):
...
AssertionError: The arguments must been from type int and 'denominator' != 0"
>>> simplify_fraction("test","test")
Traceback (most recent call last):
...
(1, 2)
>>> simplify_fraction(10,-1)
Traceback (most recent call last):
...
AssertionError: The arguments must been from type int and 'denominator' != 0"
>>> simplify_fraction("test","test")
Traceback (most recent call last):
...

@algorithms-keeper algorithms-keeper bot added the merge conflicts Open a new PR or rebase on the latest commit label Oct 11, 2023
@cclauss
Copy link
Member

cclauss commented Oct 11, 2023

There are git conflicts. This means that someone else has modified this file.

@rmp2000
Copy link
Contributor Author

rmp2000 commented Oct 11, 2023

There are git conflicts. This means that someone else has modified this file.

is my firts time doing a pull request now what I should do ? thanks

@algorithms-keeper algorithms-keeper bot removed the merge conflicts Open a new PR or rebase on the latest commit label Oct 11, 2023
@cclauss
Copy link
Member

cclauss commented Oct 11, 2023

OK. I merged the two changes together so we have two new tests plus your tests.

@rmp2000
Copy link
Contributor Author

rmp2000 commented Oct 11, 2023

OK. I merged the two changes together so we have two new tests plus your tests.

Nice, thanks for the help

@cclauss
Copy link
Member

cclauss commented Oct 11, 2023

Can you run python3 -m doctest -v maths/primelib.py on your computer which will do what our build step does?

If there is too much output, remove the -v (verbose) flag.

https://github.com/TheAlgorithms/Python/actions/runs/6480374805/job/17595777013?pr=10251#step:6:761

Scroll to line 760

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 11, 2023
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Great! Thanks for doing this.

If you wanted to create a follow-up pull request to add type hints to function signatures like we did on line 794, that would be supercool!

@cclauss cclauss merged commit 5fb6496 into TheAlgorithms:master Oct 11, 2023
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
…0251)

* Update the doctest of primelib.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Correct errors for the doctest of primelib.py

* last error for the doctest of primelib.py

* last error for the doctest of primelib.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants