summaryrefslogtreecommitdiff
path: root/yarnlib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-06-09 11:41:41 +0100
committerLars Wirzenius <liw@liw.fi>2013-06-09 11:41:41 +0100
commitfe8ce17ae1d9a4b1e7a2df1b9588fbe42bec2000 (patch)
tree0591afe85e056f7bbf06dc2a67a19d2fd25c2b14 /yarnlib
parente27d5faab95ca26dd8fcb512ec09d729e1f388b4 (diff)
downloadcmdtest-fe8ce17ae1d9a4b1e7a2df1b9588fbe42bec2000.tar.gz
Add story element classes
Diffstat (limited to 'yarnlib')
-rw-r--r--yarnlib/__init__.py2
-rw-r--r--yarnlib/elements.py51
2 files changed, 52 insertions, 1 deletions
diff --git a/yarnlib/__init__.py b/yarnlib/__init__.py
index 44e83e3..2abc3ad 100644
--- a/yarnlib/__init__.py
+++ b/yarnlib/__init__.py
@@ -17,4 +17,4 @@
from mdparser import MarkdownParser
-
+from elements import Story, StoryStep, Implementation
diff --git a/yarnlib/elements.py b/yarnlib/elements.py
new file mode 100644
index 0000000..a1dea0d
--- /dev/null
+++ b/yarnlib/elements.py
@@ -0,0 +1,51 @@
+# Copyright 2013 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+# This is a step in a story: GIVEN, WHEN, THEN, etc.
+
+class StoryStep(object):
+
+ def __init__(self, what, text):
+ self.what = what
+ self.text = text
+ self.implementation = None
+
+
+# This is the story itself.
+
+class Story(object):
+
+ def __init__(self, name):
+ self.name = name
+ self.steps = []
+
+
+# This is an IMPLEMENTS chunk.
+
+class Implementation(object):
+
+ def __init__(self, what, regexp, shell):
+ self.what = what
+ self.regexp = regexp
+ self.shell = shell
+
+ def execute(self):
+ exit, out, err = cliapp.runcmd_unchecked(
+ ['sh', '-c', 'set -eu\n' + self.shell])
+ return exit
+