Anyone managed to use flask-lettuce (even thought it is alpha) successfully? I created a hook for before_each.app where I set the flaskclient in world, but, when I tried to access it, I got a attributeerror. -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================
Hi, I'm the author of the extension, but honestly, it has been a long time since i last wrote it for a client, so I'm not sure of some of the details :) I pass a `flask.test_client_class` in before.each_app so you should be able to use it as: @before.each_app def run_database_task(client): pass please let me know if you need more clarifications On Mon, Sep 26, 2011 at 8:40 PM, Italo Maia <italo.maia@gmail.com> wrote: > Anyone managed to use flask-lettuce (even thought it is alpha) > successfully? > > I created a hook for before_each.app where I set the flaskclient in world, > but, when I tried to access it, I got a attributeerror. > > -- > "A arrogância é a arma dos fracos." > > =========================== > Italo Moreira Campelo Maia > Bacharel em Ciência da Computação - UECE > Desenvolvedor WEB e Desktop (Java, Python, Lua) > Coordenador do Pug-CE > ----------------------------------------------------- > http://www.italomaia.com/ > http://twitter.com/italomaia/ > http://eusouolobomau.blogspot.com/ > ----------------------------------------------------- > Turtle Linux 9.10 - http://tiny.cc/blogturtle910 > Turtle Linux 10.10 - http://bit.ly/cEw4ET > =========================== >
Yeap, after some headbutting I figured that client param (damn lettuce api docs are bad!). My solution, so far, was to set the client for each scenario (current_app.test_client()) and, before each feature, I create the database and after each feature, I remove the db.session and drop the database. Seems to work so far. About your code, what I did not understand were two things: first: in line 98 https://github.com/dqminh/flask-lettuce/blob/master/flaskext/lettuce.py why did you use test_request_context as request proxy is not used? second: Why did you recursively walked through path? Lettuce won't load stuff recursively by default? (ps: I tried looking this up with little succes. Lettuce API docs really piss me off!) By the way, your code was very helpful. ps: what you manage to answer will be very helpful! pss: thanks for the reply! 2011/9/26 Daniel , Dao Quang Minh <dqminh89@gmail.com> > Hi, > > I'm the author of the extension, but honestly, it has been a long time > since i last wrote it for a client, so I'm not sure of some of the details > :) > > I pass a `flask.test_client_class` in before.each_app so you should be able > to use it as: > > @before.each_app > def run_database_task(client): > pass > > please let me know if you need more clarifications > > > On Mon, Sep 26, 2011 at 8:40 PM, Italo Maia <italo.maia@gmail.com> wrote: > >> Anyone managed to use flask-lettuce (even thought it is alpha) >> successfully? >> >> I created a hook for before_each.app where I set the flaskclient in world, >> but, when I tried to access it, I got a attributeerror. >> >> -- >> "A arrogância é a arma dos fracos." >> >> =========================== >> Italo Moreira Campelo Maia >> Bacharel em Ciência da Computação - UECE >> Desenvolvedor WEB e Desktop (Java, Python, Lua) >> Coordenador do Pug-CE >> ----------------------------------------------------- >> http://www.italomaia.com/ >> http://twitter.com/italomaia/ >> http://eusouolobomau.blogspot.com/ >> ----------------------------------------------------- >> Turtle Linux 9.10 - http://tiny.cc/blogturtle910 >> Turtle Linux 10.10 - http://bit.ly/cEw4ET >> =========================== >> > > -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================
Made it! Had to create a before_each_scenario hook and create the client in it. The flask-lettuce plugin code had to be changed a little (propose patch later on). 2011/9/26 Italo Maia <italo.maia@gmail.com> > Anyone managed to use flask-lettuce (even thought it is alpha) > successfully? > > I created a hook for before_each.app where I set the flaskclient in world, > but, when I tried to access it, I got a attributeerror. > > -- > "A arrogância é a arma dos fracos." > > =========================== > Italo Moreira Campelo Maia > Bacharel em Ciência da Computação - UECE > Desenvolvedor WEB e Desktop (Java, Python, Lua) > Coordenador do Pug-CE > ----------------------------------------------------- > http://www.italomaia.com/ > http://twitter.com/italomaia/ > http://eusouolobomau.blogspot.com/ > ----------------------------------------------------- > Turtle Linux 9.10 - http://tiny.cc/blogturtle910 > Turtle Linux 10.10 - http://bit.ly/cEw4ET > =========================== > -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================