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

Add get_int_max_str_digits and set_int_max_str_digits in sys. #5014

Merged
merged 7 commits into from Jun 17, 2023

Conversation

dannasman
Copy link
Contributor

Hi!

Here is a solution proposal for issue #5010.

@youknowone
Copy link
Member

@DimitrisJim do you know if it has related tests?

@DimitrisJim
Copy link
Member

DimitrisJim commented Jun 17, 2023

oh it definitely did, that's how I remember finding it. shame I didn't mention anything in the in the issue, I'll look into it. What on earth is going on with this Mac runner though 😮‍💨 (ah ok, Dan's fork doesn't have most recent commits)

@youknowone
Copy link
Member

Don't worry about CI failure. I fixed it here https://github.com/RustPython/RustPython/pull/5012/files#diff-575a2149c1bf435cd04009918dec66fd8fa2be92cf7d5fdcdb48ceb61d3ad4aaR11

@DimitrisJim
Copy link
Member

DimitrisJim commented Jun 17, 2023

Thanks for this @dannasman. These are currently tested indirectly in test_cmd_line (this is basically an implementation -X flag that can be passed when invoking Python and we don't currently have that part implemented iirc so tests fail).

Could you by any chance add an additional test in extra_tests/snippets/stdlib_sys.py that plays with these get/set functions on a basic level? Something along the lines of get its value, make sure it equals the default, set it to a bad value, error is raised etc.

Also please rebase so we can get the most recent changes that fix that CI annoyance.

@dannasman
Copy link
Contributor Author

Sure 👍

@dannasman
Copy link
Contributor Author

dannasman commented Jun 17, 2023

I am having trouble running pytest -v with RustPython instead of my default CPython that I have installed. Do you have any tips on how to run pytest with RustPython?

Also, is this the correct way of testing whether set_int_max_str_digits raises the correct error (ValueError)?

with assert_raises(ValueError):
    sys.set_int_max_str_digits(1)

@DimitrisJim
Copy link
Member

Hey, so yeah if you run it with pytest -v you should be fine, it calls the RustPython binary itself (see test_snippets.py). Pushing directly here is also an option.

Also, is this the correct way of testing whether set_int_max_str_digits raises the correct error (ValueError)?

Yup! That looks right to me.

@DimitrisJim
Copy link
Member

DimitrisJim commented Jun 17, 2023

Jesus Christ Mac started using 3.11.4 now. I'll push a commit here if you dont mind @dannasman, the runners using different versions of Python to run the snippets has been a pain, sorry for the back and forth.

@dannasman
Copy link
Contributor Author

No problem!

Copy link
Member

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

thanks so much @dannasman, lgtm

@DimitrisJim DimitrisJim merged commit 1cdc5d3 into RustPython:main Jun 17, 2023
11 checks passed
@dannasman dannasman deleted the getset_int_max_str_digits branch June 17, 2023 20:49
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.

None yet

3 participants