Mercurial > piecrust2
comparison tests/basefs.py @ 979:45ad976712ec
tests: Big push to get the tests to pass again.
- Lots of fixes everywhere in the code.
- Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now.
- Replace all `.md` test files with `.html` since now a auto-format extension always sets the format.
- Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 29 Oct 2017 22:51:57 -0700 |
parents | 72f17534d58e |
children | 6350ee084273 |
comparison
equal
deleted
inserted
replaced
978:7e51d14097cb | 979:45ad976712ec |
---|---|
1 import os.path | 1 import os.path |
2 import yaml | 2 import yaml |
3 from piecrust.app import PieCrust | 3 from piecrust.app import PieCrust |
4 from piecrust.main import _pre_parse_chef_args, _run_chef | |
5 from piecrust.sources.base import ContentItem | 4 from piecrust.sources.base import ContentItem |
6 | 5 |
7 | 6 |
8 class TestFileSystemBase(object): | 7 class TestFileSystemBase(object): |
8 _use_chef_debug = False | |
9 _pytest_log_handler = None | |
10 _leave_mockfs = False | |
11 | |
9 def __init__(self): | 12 def __init__(self): |
10 pass | 13 pass |
11 | 14 |
12 def path(self, p): | 15 def path(self, p): |
13 raise NotImplementedError() | 16 raise NotImplementedError() |
97 self.withPage(url, config, contents) | 100 self.withPage(url, config, contents) |
98 return self | 101 return self |
99 | 102 |
100 def runChef(self, *args): | 103 def runChef(self, *args): |
101 root_dir = self.path('/kitchen') | 104 root_dir = self.path('/kitchen') |
102 chef_args = ['--root', root_dir] + args | 105 chef_args = ['--root', root_dir] |
106 if self._use_chef_debug: | |
107 chef_args += ['--debug'] | |
108 chef_args += list(args) | |
103 | 109 |
104 pre_args = _pre_parse_chef_args(chef_args) | 110 import logging |
111 from piecrust.main import ( | |
112 _make_chef_state, _recover_pre_chef_state, | |
113 _pre_parse_chef_args, _run_chef) | |
114 | |
115 # If py.test added a log handler, remove it because Chef will | |
116 # add its own logger. | |
117 if self._pytest_log_handler: | |
118 logging.getLogger().removeHandler( | |
119 self._pytest_log_handler) | |
120 | |
121 state = _make_chef_state() | |
122 pre_args = _pre_parse_chef_args(chef_args, state=state) | |
105 exit_code = _run_chef(pre_args, chef_args) | 123 exit_code = _run_chef(pre_args, chef_args) |
124 _recover_pre_chef_state(state) | |
125 | |
126 if self._pytest_log_handler: | |
127 logging.getLogger().addHandler( | |
128 self._pytest_log_handler) | |
129 | |
106 assert exit_code == 0 | 130 assert exit_code == 0 |
107 | 131 |
108 def getSimplePage(self, rel_path): | 132 def getSimplePage(self, rel_path): |
109 app = self.getApp() | 133 app = self.getApp() |
110 source = app.getSource('pages') | 134 source = app.getSource('pages') |