Samples don't work #4

Open
opened 2021-11-18 16:45:25 +01:00 by Jason · 2 comments
Collaborator

I tried both samples and found they did not work. Pull req has fixes

sample1.py
Altered the expected outputs to match what is obtained (removed elipses)
Added a repr to Parameter object so that it matches (now uses (Sumbol(x))
previous version was comparing main.x with sample1.x
add

sample2.py
Moved the ini_file_text from the main to the body, changed to a join of lists to make compatible with doctest.
Altered the expected outputs to match what is obtained (removed elipses)

Note passing ELIPSES to the doctest.testmod call does not work, you need to put # doctest: +ELIPSES on the test line.

I tried both samples and found they did not work. Pull req has fixes sample1.py Altered the expected outputs to match what is obtained (removed elipses) Added a repr to Parameter object so that it matches (now uses (Sumbol(x)) previous version was comparing __main__.x with __sample1__.x add <BLANKLINE> sample2.py Moved the ini_file_text from the __main__ to the body, changed to a join of lists to make compatible with doctest. Altered the expected outputs to match what is obtained (removed elipses) Note passing ELIPSES to the doctest.testmod call does not work, you need to put # doctest: +ELIPSES on the test line.
Poster
Collaborator

There is still a problem.

It appers lxml and etree behave every so slightly differently.

etree adds a space on single line elements.

<Parameter typing="int" name="a" />

whereas lxml does not

<Parameter typing="int" name="a"/>

This can be fixed with elipses (...)

lxml emits a CRLF at the end of the tostring() and needs a corresponding in the doctest, etree does not.

I think the answer is to always use etree for tostring even if lxml is in use as etree is in the standard library and lxml is not

There is still a problem. It appers lxml and etree behave every so slightly differently. etree adds a space on single line elements. ```xml <Parameter typing="int" name="a" /> ``` whereas lxml does not ```xml <Parameter typing="int" name="a"/> ``` This can be fixed with elipses (...) lxml emits a CRLF at the end of the tostring() and needs a corresponding <BLANKLINE> in the doctest, etree does not. I think the answer is to always use etree for tostring even if lxml is in use as etree is in the standard library and lxml is not
Poster
Collaborator

Ok I think that's fixed. adding end="" to the print prevents a trailing CRLF

Ok I think that's fixed. adding end="" to the print prevents a trailing CRLF
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fdik/pypeg2#4
There is no content yet.