-
-
Notifications
You must be signed in to change notification settings - Fork 171
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 tests for issue #355 #426
base: main
Are you sure you want to change the base?
Conversation
@NicoHood I cherry-picked your commit from #356 and there is a test failing for a content line.
It looks like a string gets split into parts if it has a space.... |
@@ -0,0 +1,8 @@ | |||
BEGIN:VEVENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this file added? It seems completely identical to your test file
The string does not get split into parts if it has a space. You can clearly see the space in your result. It is split, when a backslash is being escaped. I currently try to understand why, but the test itself looks like a horrible syntax. Can we please fix it and make it use python fstrings? |
Alright, so I can see what is happening here. This is the failing test:
And this is the function that splits up our string: icalendar/src/icalendar/parser.py Line 227 in 832a166
It will recognize The RFC section that describes this process is this one: It seems that I have not implemented it correctly and for me it is still a brainfuck to understand how it should be implemented. Which strings can be quoted and which not. I think this needs more detailed parsing, but we can get to that. |
So I looked at the mentioned spec and I could not find any part, where escaping of those characters in the test are described. I am wondering where this was defined, in which spec? Otherwise I am unable to fix anything here. This is what I understood from the spec:
It seems in my implementation I made the mistake to quote those characters by using a backslash. But the test also looks incorrect. If those parameter value are not quoted (which they are not) they should be split by a comma. And that is what the code does now. I have to think about this some more, but there seems to be a lot wrong. Before my PR but also with. We need to document the code much more, it is totally confusing and not understandable. |
Maybe we should just take the abnf and convert it to a regex? It might be a bad idea, I dont know yet, but the abnf itself should be as close to the spec as we can get. https://github.com/aas-core-works/abnf-to-regexp |
Hm... Which interface do we have to fulfill for parsing these parameters?
Can you link that here? Here is a list of tests that can be written and parametrized with different values to make sure it is working.
(1) One proposal would be that I write tests and you can use TDD to work a bit more on the code. (2) Another proposal is to just fix this little test to be accurate: Is the problem that the current implementation does not distinct between (L1) and (L2) above? |
Yeah, if you can write tests first, that would help me a lot. This way we can talk clearer about the spec and how it should look like. |
I think, I need the examples mentioned. From what you write, I guess that writing tests is out of what you usually do or out of the comfort zone. The code that you wrote however is much more complicated than writing the test case for it. Of you give it a try, I am happy to guide you. The next steps seem to be gathering examples. Very likely they are already mostly implemented. Also, if the test case is wrong, we should change it. Do you think it is wrong? It seems so as it has no " in it. So, what would be your course of action here?
|
I will have a look at it this week. I will let you know of my progress |
see #356
see #355
@NicoHood - I created this PR to make sure the tests work.