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

test_function_definition: can we test_object within it? #9

Closed
hugobowne opened this issue May 26, 2016 · 4 comments
Closed

test_function_definition: can we test_object within it? #9

hugobowne opened this issue May 26, 2016 · 4 comments

Comments

@hugobowne
Copy link

hi! i love that you can test_function within test_function_definition: can we also test objects within the scope?

@franciscastro tried but to no avail yet. If so, could you possibly provide a quick example of usage in the case of this exercise:

https://campus.datacamp.com/courses/1113/2464?ex=3
thanks!

@vvnkr
Copy link
Member

vvnkr commented May 26, 2016

Have you tried using test_object_after_expression()?

test_function_definition('shout', body = lambda: test_object_after_expression('shout_word'))

test_object() only works in the global scope.

However Filip and me have been thinking about making the notation to test things more 'Pythonic'. These functions are actually in this kind of format (with the lambda/custom defined functions and stuff), because that's how it was done in R. However in Pyhton in might make more sense to write the test you'd like to do like this:

Below is an idea, code won't work

test_function_definition('shout').get_body().test_object('shout_word')

This could make testing in Python more "object-oriented-ish". You could go to a notation like this:

shout_def_body = test_function_definition('shout').get_body()
shout_def_body.test_object('shout_word')
shout_def_body.test_function(...)
shout_def_body.test_if_else(...)

I'm sure we'll discuss this further when Filip's back. Might be interesting to include you in that conversation to get your feedback.

@hugobowne
Copy link
Author

@franciscastro and I will try test_object_after_expression() and let you know how it goes!

@vvnkr
Copy link
Member

vvnkr commented May 27, 2016

@hugobowne did you figure it out?

@hugobowne
Copy link
Author

test_function_definition('shout', body = lambda: test_object_after_expression('shout_word')) works!

@vincentvankrunkelsven

i agree we should discuss a more more "object-oriented-ish" python sct with filip :-)

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

No branches or pull requests

2 participants