def test_bad_file(): filename = os.path.join( os.path.dirname( os.path.dirname(__file__) ), 'fixtures', 'test_settings', 'empty.yaml' ) with pytest.raises(ConfigError) as ctx: Script.from_file(filename) assert ctx.value.args[0] == ( 'Script must be a collection of key-value pairs.' )
def test_from_file(): filename = os.path.join( os.path.dirname( os.path.dirname(__file__) ), 'fixtures', 'test_settings', 'script.yaml' ) def err(ex): raise ex script = Script.from_file(filename) script.on('line.error', err) script.run() bucket = script.storage.bucket('tests.actors.settings') assert bucket.get('foo') == 'baz'