Skip to content

Support embedding Text test cases into Markdown files - #2621

Closed
vairamsvsjdo wants to merge 4 commits into
robotframework:masterfrom
JayDevOps:support-md-tc
Closed

vairamsvsjdo wants to merge 4 commits into
robotframework:masterfrom
JayDevOps:support-md-tc

Conversation

@vairamsvsjdo

@vairamsvsjdo vairamsvsjdo commented Jun 19, 2017 •

Copy link
Copy Markdown

Support embedding Text test cases into Markdown files
fixes issue: #2610

@vairamsvsjdo

Copy link
Copy Markdown
Author

Navigating through legacy code constructs in robotframework:

  1. robotframework code several of them don't comply with PEP8 conventions: example, populators.py did not meet PEP8 and comment requirement.
  2. where is utest for restreader? (I was looking for a sample to use for creating utest for mdreader.py)
  3. Is there a contribution recommendations for using a file as test resource or use the complex route of html reader.? I am not sold on htmlreader test method. thoughts?

@vairamsvsjdo vairamsvsjdo changed the title fixes issue https://github.com/robotframework/robotframework/issues/2610 Support embedding Text test cases into Markdown files Jun 19, 2017

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The approach used looks fine but there were several things that ought to be fixed in the code. Need to also discuss about testing and documentation separately.

Comment thread src/robot/parsing/mdreader.py Outdated
from .txtreader import TxtReader


def MarkDownReader():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's no need for this extra factory function. RestReader uses it because the factory imports the external docutils module. This reader needs no external dependencies and MarkdownReader could simply be a class.

Comment thread src/robot/parsing/mdreader.py Outdated
Log hello world from markdown console=yes
```
## Some more documentation
'''

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think docstring is too useful. Documentation in general belongs to the User Guide and acknowledgements into AUTHORS.txt, commit messages or elsewhere. In general we've used docstrings only when documenting the public interfaces.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agreed, will make appropriate change

Comment thread src/robot/parsing/mdreader.py Outdated
self.robot_data = ''

def robotize(self, md_file):
f = StringIO(md_file.read().decode('UTF-8'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wrapping the read data into a StringIO makes no sense. Much easier to just iterate over the lines of the original file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

makes sense, will make appropriate change.

Comment thread src/robot/parsing/mdreader.py Outdated
include_line = False
else:
self.robot_lines.append(line)
self.robot_data = str(''.join(self.robot_lines))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using str here is totally unnecessary. It also causes UnicodeDecodeError with Python 2 if the data happens to contain non-ASCII characters.

from .restreader import RestReader

from .mdreader import MarkDownReader

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should have two empty lines after imports.

from .mdreader import MarkDownReader

READERS = {'html': HtmlReader, 'htm': HtmlReader, 'xhtml': HtmlReader,
'tsv': TsvReader , 'rst': RestReader, 'rest': RestReader,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixing small PEP-8 errors here in the code that you edit is fine, but in general it would be better to have them in separate PRs. Having lot of unrelated changes in a PR makes reviewing it harder.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agreed

table = self._datafile.start_table(DataRow(header).all)
self._populator = self._populators[table.type](table) \
if table is not None else NullPopulator()
if table is not None else NullPopulator()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I already commented, PEP-8 fixes in general belong to own PRs. In this particular case I also happen to like the original style better. Using four spaces for indentation when continuing a line is confusing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agreed

@pekkaklarck

Copy link
Copy Markdown
Member

Answers to your questions:

  1. I'm sure there are PEP-8 violations still in the code and especially in unit tests. Fixing them is fine, but fixes to code that isn't otherwise edited by this PR should rather be moved into their own PR.

  2. I'm not sure does RestReader have unit tests. It could be thoroughly tested with acceptance tests.

  3. Could you clarify what you mean with the complex route in testing HtmlReader? Also, please read CONTRIBUTING.rst and atest/README.rst for information about testing in general.

@vairamsvsjdo

Copy link
Copy Markdown
Author
  1. agreed
  2. Its at least not there in the test parsing folder.
  3. Please ignore that.

@vairamsvsjdo

Copy link
Copy Markdown
Author

@pekkaklarck I was able to find atest for rest:
However, have these questions:

  1. These tests seems to duplicate:
    rest
    restdirective

  2. As I was reviewing the atest test cases, I am realizing the volume of different use cases that markdown file format needs to support as equivalent to Rest. Does this pull request meet all those test cases or can this be as different features.

2. Added atest for markdown format
3. Todo: change mdreader finalize changes.
@vairamsvsjdo

Copy link
Copy Markdown
Author

@pekkaklarck made changes as requested

@pekkaklarck

Copy link
Copy Markdown
Member

Great! Unfortunately I don't have time for a review in immediate future but I hopefully have time for this next week or week after that.

@vairamsvsjdo

Copy link
Copy Markdown
Author

Great, thanks

@pekkaklarck

Copy link
Copy Markdown
Member

Development hasn't been too active in the past, but we are starting RF 3.1 development and I'd like to get this enhancement in. On a quick look the approach used looks pretty good, but there are some places where code could be cleaned up a little. For example, imports weren't in format recommended by PEP-8. More importantly, some of the tests looked pretty strange with Robot data inside the code blocks formatted as tables like this:

=============  =========  ==============  ===============
  Settings       Value         Value           Value
=============  =========  ==============  ===============
 Default Tags   default1
=============  =========  ==============  ===============

My guess is that these are copied from the current reStructuredText tests, where this format is used when the idea is to convert reST files to HTML and parse them then. We are going to deprecate and remove the support for using HTML data (as well as reST what is converted to HTML), so supporting anything like that with Markdown doesn't make sense either. The current code doesn't seem to support this either, so I would assume it's enough to just remove these tests.

@pekkaklarck pekkaklarck reopened this Apr 26, 2018
@vairamsvsjdo

Copy link
Copy Markdown
Author

@pekkaklarck This was assumed at the time of making it work in markdown, we decided in our implementation to use reST format such that it will enable us to see these in markdown with syntax highlighting and work as a document for Acceptance Testing.

Please provide how you envision and will make changes accordingly.
What formats are we looking to support?
How do you see a test script must look embedded with other documentation.

@pekkaklarck

Copy link
Copy Markdown
Member

We got new parser in RF 3.2 (#3076) and this PR is incompatible with it. Support for Markdown would be a nice addition, though, and adding it on top of the new parser ought to be easier than it was earlier.

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.

2 participants