pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.31k stars 220 forks source link

Wrong feature description parsing. #144

Closed spinus closed 9 years ago

spinus commented 9 years ago

I'm working on HTML reported and as well as Terminal reporter.

I need to "recreate" texts. I was going to use stuff which is available in pytest-bdd pytest reports. Here is what I have when accessing __scenario__:

{'tags': ['OK'], 'steps': [{'name': 'background OK', 'line_number': 11, 'duration': 0.00015592575073242188, 'failed': False, 'type': 'given', 'keyword': 'Given'}, {'name': 'OK', 'line_number': 25, 'duration': 0.000125885009765625, 'failed': False, 'type': 'given', 'keyword': 'Given'}, {'name': 'OK', 'line_number': 26, 'duration': 5.91278076171875e-05, 'failed': False, 'type': 'when', 'keyword': 'When'}, {'name': 'OK', 'line_number': 27, 'duration': 5.698204040527344e-05, 'failed': False, 'type': 'then', 'keyword': 'Then'}], 'feature': {'description': 'In order to achieve something\nI want something\nBecause it will be cool\nSome description goes here.', 'tags': [], 'filename': '/home/spinus/Projekty/something/features/designer_login.feature', 'line_number': 1, 'rel_filename': 'features/designer_login.feature', 'name': 'Designer can log in'}, 'name': 'OK', 'line_number': 24}

It's almost good, but original description of feature is:

Feature: Designer can log in

  In order to achieve something
  I want something
  Because it will be cool

  Some description goes here.

So as you can see, two new lines are missing before last line.

bubenkoff commented 9 years ago

nice catch! PR is welcome

olegpidsadnyi commented 9 years ago

I guess it is related to the

    if not clean_line:
        continue

You could use this feature file for the test

spinus commented 9 years ago

I'll take a look at some point (probably after reporters) so if you find time go for it.

spinus commented 9 years ago

@bubenkoff nice stuff. Thank you.