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

Strip whitespace before parsing in seval #380

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

LilithHafner
Copy link
Contributor

Fixes #379

I'm not sure how to add tests for this. I don't see tests from the Python side.

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 10, 2023

Thanks! You could use #379 (comment) as the basis of some tests.

@LilithHafner
Copy link
Contributor Author

Okay, I put tests in test/utils.jl and tested this from the Julia side. Are there no CI tests with Python as the host language?

test/utils.jl Outdated
m = Py(Main)
@test m.seval("1 + 1") === 2 # Basic behavior
@test m.seval("1 + 1\n ") === 2 # Trailing whitespace
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you move the test to

@testitem "module" begin
please?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also these tests are failing because m.seval(...) returns a Py.

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 10, 2023

Are there no CI tests with Python as the host language?

There are, under pytest. These get run in CI along with the Julia tests.

Currently all the Python-side tests do is check that import juliacall doesn't raise an exception.

@LilithHafner
Copy link
Contributor Author

LilithHafner commented Oct 10, 2023

My inclination would be to test this on the python side the way it came up in the wild, like this

@LilithHafner
Copy link
Contributor Author

Where is test_import called from?

@LilithHafner
Copy link
Contributor Author

FWIW this is not a problem in Julia 1.10+, but it's still probably worth fixing here for compatibility with 1.6/1.9.

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 10, 2023

My inclination would be to test this on the python side the way it came up in the wild, like this

I'd prefer the tests back in Julia, since that's where it's defined (it's more of a unit test that way).

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 10, 2023

Where is test_import called from?

It's called by magic. When you run the pytest program, it searches for functions called test_something and executes them.

@LilithHafner
Copy link
Contributor Author

So I'm assuming the new function I added is also called by magic. Is that test acceptable to you or would you like me to move it back to the Julia side?

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 10, 2023

So I'm assuming the new function I added is also called by magic. Is that test acceptable to you or would you like me to move it back to the Julia side?

Yes indeed. Back to Julia please - I'd like to keep the Python tests restricted to just the things extra that JuliaCall itself gives you.

@cjdoris cjdoris merged commit 16c2374 into JuliaPy:main Oct 11, 2023
13 checks passed
@cjdoris
Copy link
Collaborator

cjdoris commented Oct 11, 2023

Thanks muchly!

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.

Main.seval fails to strip whitespace and therefore throws when it shouldn't.
2 participants