def prosaic(*args) -> Result: """Helper function for running prosaic.main, mimicking use from the command line. Sets argv to be ['prosaic'] + whatever is passed as args. Returns the exit code prosaic would have returned.""" # TODO pass an argv to main; leave sys alone sys.argv = ['prosaic'] + list(args) + ['--home', TEST_PROSAIC_HOME] buff = io.StringIO() code = None with patch('prosaic.cfg.read_config', return_value=TEST_CONFIG): with redirect_stdout(buff): code = main() buff.seek(0) result = buff.read() lines = set(result.split('\n')[0:-1]) return Result(lines=lines, code=code)
def test_initialization_and_reading(self, cleanup): sys.argv = ['prosaic', 'corpus', 'ls', '--home', TEST_PROSAIC_HOME] main() config = cfg.read_config(join(TEST_PROSAIC_HOME, 'prosaic.conf')) assert cfg.DEFAULT_DB == config['database'] assert cfg.DEFAULT_TEMPLATE == config['default_template']