Closed hugobowne closed 7 years ago
Hi @hugobowne I'll look into this this week. Could you be a bit more specific as to what you steps want to test:
@filipsch great question. I like to think of comprehensions as being really cool for loops that potentially contain other control flow statements. There is much information condensed in comprehensions so there are many things to test.
I will refer to the following example below:
x = [doc[0] for doc in doctor if doc[1] == 'h']
We need to test the following:
doctor
above)?doc
above)? (we want to test this only sometimes, i.e. when we specify the iterator in the instructions);doc[0]
above)?if doc[1] == h
above)?if len(member) >= 7 else ''
in the example below)?As we need to test conditionals, might it make sense to have test_if_else
tests embedded in test_comprehension
tests? A thought.
Whatever happens, I am pumped for this!!
@hugobowne Thanks for this detailed step-by-step guide, this is the way to go for future issues!
To embed test_if_else()
inside a comprehension, I'll provide a body
test, so that you can pass a 'sub-SCT' to check the body of the list comprehension, just like with test_lambda_function()
and test_function_definition()
. You're free to use any sct functions in there.
As I said, I am currently working on revising the entire internal workings of pythonwhat
so that plots are no longer messed up; I'll try to work on this Monday August 15.
@hugobowne
Due to delays in rolling out the new python backend this functionality probably won't be available by the time you want to do beta testing.
For the moment, I'd work with 'indirect SCTs', i.e. using for example test_object()
to see if the correct object was created with list comprehension.
I'll let you know when test_list_comprehension()
is implemented and live.
@filipsch thanks for the update. I'll think about this. My initial intuition says to wait to until test_list_comp
is live to beta test. The reason is that I have an entire chapter on list comps & generators (plus a large portion of the final case study chapter); the point of the chapter is teaching them
[output expression + conditional for iterator variable in iterable + conditional]
I build up these components and need to provide tailored feedback on each component.
What is new ETA on test_list_comp
?
@hugobowne hard to say. Depends on how fast we can roll out the new version of pythonwhat. I'd say end of week at the latest, is that acceptable?
@filipsch definitely acceptable! :-D
@hugobowne functionality has been written, it's under review now and will go live with the big update of pythonwhat, hopefully beginning of next week. You can already read up on it in the wiki: https://github.com/datacamp/pythonwhat/wiki/test_comprehension If I close this issue, this means the feature will be available on production.
We'll need to test comprehensions (list/dict/set); e.g. for
we will need an SCT for
Also conditional comps such as
and nested comps! ;-)