- commit
- aec6da36fb2c88545fc2c4c3888e701d3f69bf46
- parent
- cde052f2aebac0906b2a61dd31f5f2ddc30add07
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-02-09 07:58
rename unit to suite
Diffstat
| M | assamtest/__init__.py | 18 | +++++++++--------- |
| M | assamtest/__main__.py | 6 | +++--- |
| M | assamtest/reporter.py | 8 | ++++---- |
| M | assamtest/runner.py | 32 | ++++++++++++++++---------------- |
4 files changed, 32 insertions, 32 deletions
diff --git a/assamtest/__init__.py b/assamtest/__init__.py
@@ -1,21 +1,21 @@1 -1 stack = [{'tests': [], 'units': []}]-1 1 stack = [{'tests': [], 'suites': []}] 2 2 3 34 -1 def _unit_push():5 -1 stack.append({'tests': [], 'units': []})-1 4 def _suite_push(): -1 5 stack.append({'tests': [], 'suites': []}) 6 6 7 78 -1 def _unit_pop(name):-1 8 def _suite_pop(name): 9 9 tmp = stack.pop()10 -1 if tmp['tests'] or tmp['units']:11 -1 stack[-1]['units'].append((name, tmp))-1 10 if tmp['tests'] or tmp['suites']: -1 11 stack[-1]['suites'].append((name, tmp)) 12 12 13 1314 -1 def unit(name=None):-1 14 def suite(name=None): 15 15 def decorator(fn):16 -1 _unit_push()-1 16 _suite_push() 17 17 fn()18 -1 _unit_pop(name or fn.__name__)-1 18 _suite_pop(name or fn.__name__) 19 19 return fn 20 20 return decorator 21 21
diff --git a/assamtest/__main__.py b/assamtest/__main__.py
@@ -4,7 +4,7 @@ import sys 4 4 import importlib 5 5 import pkgutil 6 67 -1 from . import stack, _unit_push, _unit_pop-1 7 from . import stack, _suite_push, _suite_pop 8 8 from .reporter import SpecReporter 9 9 from .runner import run 10 10 @@ -15,9 +15,9 @@ def import_package(path): 15 15 if d.endswith('__init__.py'): 16 16 d = os.path.dirname(d) 17 17 for _, name, _ in pkgutil.iter_modules([d]):18 -1 _unit_push()-1 18 _suite_push() 19 19 import_package(path + '.' + name)20 -1 _unit_pop(name)-1 20 _suite_pop(name) 21 21 22 22 23 23 def parse_args():
diff --git a/assamtest/reporter.py b/assamtest/reporter.py
@@ -20,10 +20,10 @@ class Reporter: 20 20 def leave_run(self): 21 21 pass 22 2223 -1 def enter_unit(self, name):-1 23 def enter_suite(self, name): 24 24 pass 25 2526 -1 def leave_unit(self, name):-1 26 def leave_suite(self, name): 27 27 pass 28 28 29 29 def test(self, name, result): @@ -51,11 +51,11 @@ class SpecReporter(Reporter): 51 51 if self.stats['fail']: 52 52 return 1 53 5354 -1 def enter_unit(self, name):-1 54 def enter_suite(self, name): 55 55 self._print(name) 56 56 self.stack.append(name) 57 5758 -1 def leave_unit(self, name):-1 58 def leave_suite(self, name): 59 59 self.stack.pop() 60 60 61 61 def test(self, name, result):
diff --git a/assamtest/runner.py b/assamtest/runner.py
@@ -5,16 +5,16 @@ def run_test(test): 5 5 return e 6 6 7 78 -1 def _run(unit, reporter, before_each=[], after_each=[]):9 -1 if 'before_each' in unit:10 -1 before_each = before_each + [unit['before_each']]11 -1 if 'after_each' in unit:12 -1 after_each = [unit['after_each']] + after_each-1 8 def _run(suite, reporter, before_each=[], after_each=[]): -1 9 if 'before_each' in suite: -1 10 before_each = before_each + [suite['before_each']] -1 11 if 'after_each' in suite: -1 12 after_each = [suite['after_each']] + after_each 13 1314 -1 if 'before' in unit:15 -1 unit['before']()-1 14 if 'before' in suite: -1 15 suite['before']() 16 1617 -1 for name, test in unit['tests']:-1 17 for name, test in suite['tests']: 18 18 for fn in before_each: 19 19 fn() 20 20 @@ -23,16 +23,16 @@ def _run(unit, reporter, before_each=[], after_each=[]): 23 23 for fn in after_each: 24 24 fn() 25 2526 -1 for name, subunit in unit['units']:27 -1 reporter.enter_unit(name)28 -1 _run(subunit, reporter, before_each=before_each, after_each=after_each)29 -1 reporter.leave_unit(name)-1 26 for name, subsuite in suite['suites']: -1 27 reporter.enter_suite(name) -1 28 _run(subsuite, reporter, before_each=before_each, after_each=after_each) -1 29 reporter.leave_suite(name) 30 3031 -1 if 'after' in unit:32 -1 unit['after']()-1 31 if 'after' in suite: -1 32 suite['after']() 33 33 34 3435 -1 def run(unit, reporter):-1 35 def run(suite, reporter): 36 36 reporter.enter_run()37 -1 _run(unit, reporter)-1 37 _run(suite, reporter) 38 38 return reporter.leave_run()