diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-14 15:32:18 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-14 15:44:13 +0300 |
commit | e6746593fddd0f74966ddca0ba311805f31977f1 (patch) | |
tree | 93289408b67f3f68328f8e3eba446976e964782c | |
parent | cd5c2feed83b00f4f794d3e4df3acda9c4ba6a1f (diff) | |
download | vmdb2-e6746593fddd0f74966ddca0ba311805f31977f1.tar.gz |
Drop YarnHelper.get_next_match and related code
-rw-r--r-- | yarns/yarnhelper.py | 12 | ||||
-rw-r--r-- | yarns/yarnhelper_tests.py | 34 |
2 files changed, 0 insertions, 46 deletions
diff --git a/yarns/yarnhelper.py b/yarns/yarnhelper.py index 732562a..a1f9c8a 100644 --- a/yarns/yarnhelper.py +++ b/yarns/yarnhelper.py @@ -32,20 +32,8 @@ variables_filename = os.environ.get('VARIABLES', 'vars.yaml') class YarnHelper(object): def __init__(self): - self._env = dict(os.environ) - self._next_match = 1 self._variables = None # None means not loaded, otherwise dict - def set_environment(self, env): - self._env = dict(env) - - def get_next_match(self): - name = 'MATCH_{}'.format(self._next_match) - if name not in self._env: - raise Error('no next match') - self._next_match += 1 - return self._env[name] - def get_variable(self, name): if self._variables is None: self._variables = self._load_variables() diff --git a/yarns/yarnhelper_tests.py b/yarns/yarnhelper_tests.py index 5290944..f42a10a 100644 --- a/yarns/yarnhelper_tests.py +++ b/yarns/yarnhelper_tests.py @@ -22,40 +22,6 @@ import unittest import yarnhelper -class GetNextMatchTests(unittest.TestCase): - - def test_raises_error_if_no_next_match(self): - h = yarnhelper.YarnHelper() - h.set_environment({}) - with self.assertRaises(yarnhelper.Error): - h.get_next_match() - - def test_returns_first_match_if_there(self): - h = yarnhelper.YarnHelper() - h.set_environment({ - 'MATCH_1': 'first', - }) - self.assertEqual(h.get_next_match(), 'first') - - def test_returns_second_match_if_there(self): - h = yarnhelper.YarnHelper() - h.set_environment({ - 'MATCH_1': 'first', - 'MATCH_2': 'second', - }) - self.assertEqual(h.get_next_match(), 'first') - self.assertEqual(h.get_next_match(), 'second') - - def test_raises_error_if_no_more_matches(self): - h = yarnhelper.YarnHelper() - h.set_environment({ - 'MATCH_1': 'first', - }) - self.assertEqual(h.get_next_match(), 'first') - with self.assertRaises(yarnhelper.Error): - h.get_next_match() - - class PersistentVariableTests(unittest.TestCase): def setUp(self): |