Mercurial > piecrust2
comparison tests/conftest.py @ 1187:161cba5d031a
tests: pytest deprecated API
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 15 Jun 2021 22:34:51 -0700 |
parents | 978ed6deea91 |
children |
comparison
equal
deleted
inserted
replaced
1186:2ead9dcb6bec | 1187:161cba5d031a |
---|---|
60 | 60 |
61 def pytest_collect_file(parent, path): | 61 def pytest_collect_file(parent, path): |
62 if path.ext == '.yaml' and path.basename.startswith("test"): | 62 if path.ext == '.yaml' and path.basename.startswith("test"): |
63 category = os.path.basename(path.dirname) | 63 category = os.path.basename(path.dirname) |
64 if category == 'bakes': | 64 if category == 'bakes': |
65 return BakeTestFile(path, parent) | 65 return BakeTestFile.from_parent(parent, fspath=path) |
66 elif category == 'cli': | 66 elif category == 'cli': |
67 return ChefTestFile(path, parent) | 67 return ChefTestFile.from_parent(parent, fspath=path) |
68 elif category == 'servings': | 68 elif category == 'servings': |
69 return ServeTestFile(path, parent) | 69 return ServeTestFile.from_parent(parent, fspath=path) |
70 | 70 |
71 | 71 |
72 def repr_nested_failure(excinfo): | 72 def repr_nested_failure(excinfo): |
73 # PyTest sadly doesn't show nested exceptions so we have to do it | 73 # PyTest sadly doesn't show nested exceptions so we have to do it |
74 # ourselves... it's not pretty, but at least it's more useful. | 74 # ourselves... it's not pretty, but at least it's more useful. |
87 Loader=yaml.SafeLoader) | 87 Loader=yaml.SafeLoader) |
88 for i, item in enumerate(spec): | 88 for i, item in enumerate(spec): |
89 name = '%s_%d' % (self.fspath.basename, i) | 89 name = '%s_%d' % (self.fspath.basename, i) |
90 if 'test_name' in item: | 90 if 'test_name' in item: |
91 name += '_%s' % item['test_name'] | 91 name += '_%s' % item['test_name'] |
92 yield self.__item_class__(name, self, item) | 92 yield self.__item_class__.from_parent(self, name=name, spec=item) |
93 | 93 |
94 | 94 |
95 class YamlTestItemBase(pytest.Item): | 95 class YamlTestItemBase(pytest.Item): |
96 def __init__(self, name, parent, spec): | 96 def __init__(self, name, parent, spec): |
97 super(YamlTestItemBase, self).__init__(name, parent) | 97 super(YamlTestItemBase, self).__init__(name, parent) |