from behave.formatter.base import Formatter


class PlainFormatter(Formatter):
    name = 'plain'
    description = 'Very basic formatter with maximum compatibility'

    def __init__(self, stream, config):
        super(PlainFormatter, self).__init__(stream, config)
        self.steps = []

        self.show_timings = config.show_timings

    def feature(self, feature):
        self.stream.write(u'%s: %s\n' % (feature.keyword, feature.name))

    def background(self, background):
        self.stream.write(u'%s: %s\n' % (background.keyword, background.name))

    def scenario(self, scenario):
        self.stream.write(u'%11s: %s\n' % (scenario.keyword, scenario.name))

    def scenario_outline(self, outline):
        self.stream.write(u' %s: %s\n' % (outline.keyword, outline.name))

    def step(self, step):
        self.steps.append(step)

    def result(self, result):
        step = self.steps.pop(0)
        # TODO right-align the keyword to maximum keyword width?
        self.stream.write(u'%12s %s ... ' % (step.keyword, step.name))

        status = result.status
        if self.show_timings:
            status += " in %0.2fs" % step.duration

        if result.error_message:
            self.stream.write(u'%s\n%s\n' % (status, result.error_message))
        else:
            self.stream.write(u'%s\n' % status)

@@ -1,8 +1,33 @@
+# -*- coding: utf-8 -*-%0A%0A
 from beh
@@ -97,16 +97,174 @@
 atter):%0A
+    %22%22%22%0A    Provides a simple plain formatter without coloring/formatting.%0A    In addition, multi-line text and tables are not shown in output (SAD).%0A    %22%22%22%0A
     name
@@ -468,17 +468,16 @@
 ps = %5B%5D%0A
-%0A
         
@@ -517,16 +517,68 @@
 imings%0A%0A
+    def reset_steps(self):%0A        self.steps = %5B%5D%0A%0A
     def 
@@ -597,24 +597,51 @@
 , feature):%0A
+        self.reset_steps()%0A
         self
@@ -854,16 +854,43 @@
 nario):%0A
+        self.reset_steps()%0A
         
@@ -996,24 +996,51 @@
 , outline):%0A
+        self.reset_steps()%0A
         self

FIX issue #35: --format=plain w/ tags filtering showed wrong steps. Reset steps now.