beep On Saturday, August 8, 2015, Mauro Troiaio <mauro....@gmail.com> wrote:
> > > Inviato da iPhone > > > Il giorno 08/ago/2015, alle ore 12:00, python-requ...@lists.python.it > <javascript:;> ha scritto: > > > > Invia le richieste di iscrizione alla lista Python all'indirizzo > > python@lists.python.it <javascript:;> > > > > Per iscriverti o cancellarti attraverso il web, visita > > http://lists.python.it/mailman/listinfo/python > > oppure, via email, manda un messaggio con oggetto `help' all'indirizzo > > python-requ...@lists.python.it <javascript:;> > > > > Puoi contattare la persona che gestisce la lista all'indirizzo > > python-ow...@lists.python.it <javascript:;> > > > > Se rispondi a questo messaggio, per favore edita la linea dell'oggetto > > in modo che sia più utile di un semplice "Re: Contenuti del digest > > della lista Python..." > > > > > > Argomenti del Giorno: > > > > 1. Mockare aiohttp per tests (flandero) > > 2. Re: Mockare aiohttp per tests (Manlio Perillo) > > 3. Re: Mockare aiohttp per tests (flandero) > > 4. Re: Mockare aiohttp per tests (Manlio Perillo) > > 5. Re: Mockare aiohttp per tests (enrico franchi) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Fri, 7 Aug 2015 16:50:32 +0200 > > From: flandero <fland...@gmail.com <javascript:;>> > > To: Discussioni generali sul linguaggio Python > > <python@lists.python.it <javascript:;>> > > Subject: [Python] Mockare aiohttp per tests > > Message-ID: > > <CANkwUuYfEdy6a6vg4C-nBokz1V7jD=lq-kz7wkmpfvtuptk...@mail.gmail.com > <javascript:;>> > > Content-Type: text/plain; charset="utf-8" > > > > Ciao, > > sto usando una library per mockare su requests, chiamata httpretty. Un > > codice tipo questo: > > > > import httpretty > > import requests > > @httpretty.httprettified > > def prova(): > > httpretty.register_uri(method=httpretty.POST,uri='http://url/ > ',body='ciao > > ciao') > > requests.post('http://url/', data={'a': 1}) > > print(httpretty.last_request().body) > > > > Molto bello, e rende testabili componenti che altrimenti non lo > sarebbero. > > > > La faccenda si complica quando inizio a testare codice asincrono, in cui > ho > > usato aiohttp e non requests, perché non ho niente di simile per aiohttp. > > Dopo qualche ora di infruttuosa ricerca ho deciso di scrivere questa > mail: > > mi serve qualcosa che mi permetta di mockare aiohttp come fa httpretty > con > > requests. > > > > Ogni suggerimento, quindi, è ben accetto. Grazie! :-) > > -------------- parte successiva -------------- > > Un allegato HTML è stato rimosso... > > URL: < > http://lists.python.it/pipermail/python/attachments/20150807/1c4faaa8/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 2 > > Date: Fri, 7 Aug 2015 17:42:32 +0200 > > From: Manlio Perillo <manlio.peri...@gmail.com <javascript:;>> > > To: Discussioni generali sul linguaggio Python > > <python@lists.python.it <javascript:;>> > > Subject: Re: [Python] Mockare aiohttp per tests > > Message-ID: > > <caatoxaeqm_hrh3vba-p6hmrcxoqiicabksn9vpv4lznuwr5...@mail.gmail.com > <javascript:;>> > > Content-Type: text/plain; charset="utf-8" > > > > 2015-08-07 16:50 GMT+02:00 flandero <fland...@gmail.com <javascript:;>>: > > > >> Ciao, > >> sto usando una library per mockare su requests, chiamata httpretty. Un > >> codice tipo questo: > >> > >> import httpretty > >> import requests > >> @httpretty.httprettified > >> def prova(): > >> httpretty.register_uri(method=httpretty.POST,uri='http://url/ > ',body='ciao > >> ciao') > >> requests.post('http://url/', data={'a': 1}) > >> print(httpretty.last_request().body) > >> > >> Molto bello, e rende testabili componenti che altrimenti non lo > sarebbero. > > Io quando devo testare un client HTTP lancio un server WSGI in un > processo > > separato (multiprocessing), > > utilizzando una Queue per la comunicazione. > > > >> [...] > > > > Ciao Manlio > > -------------- parte successiva -------------- > > Un allegato HTML è stato rimosso... > > URL: < > http://lists.python.it/pipermail/python/attachments/20150807/c97e3060/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 3 > > Date: Fri, 7 Aug 2015 18:41:58 +0200 > > From: flandero <fland...@gmail.com <javascript:;>> > > To: Discussioni generali sul linguaggio Python > > <python@lists.python.it <javascript:;>> > > Subject: Re: [Python] Mockare aiohttp per tests > > Message-ID: > > <cankwuuacls_a9vnfc-aexdv2+r6r9rz0xbatj6nc2hfzpzj...@mail.gmail.com > <javascript:;>> > > Content-Type: text/plain; charset="utf-8" > > > > La cosa bella e' che lavorando con asyncio non avrei neanche bisogno di > > multiprocessing e queues, ma cosi' non si sconfina dal contesto test di > > unita' a quello dei test di interoperabilita'? > >> On Aug 7, 2015 5:42 PM, "Manlio Perillo" <manlio.peri...@gmail.com > <javascript:;>> wrote: > >> > >> 2015-08-07 16:50 GMT+02:00 flandero <fland...@gmail.com <javascript:;> > >: > >> > >>> Ciao, > >>> sto usando una library per mockare su requests, chiamata httpretty. Un > >>> codice tipo questo: > >>> > >>> import httpretty > >>> import requests > >>> @httpretty.httprettified > >>> def prova(): > >>> httpretty.register_uri(method=httpretty.POST,uri='http://url/ > ',body='ciao > >>> ciao') > >>> requests.post('http://url/', data={'a': 1}) > >>> print(httpretty.last_request().body) > >>> > >>> Molto bello, e rende testabili componenti che altrimenti non lo > sarebbero. > >> Io quando devo testare un client HTTP lancio un server WSGI in un > processo > >> separato (multiprocessing), > >> utilizzando una Queue per la comunicazione. > >> > >>> [...] > >> > >> Ciao Manlio > >> > >> _______________________________________________ > >> Python mailing list > >> Python@lists.python.it <javascript:;> > >> http://lists.python.it/mailman/listinfo/python > > -------------- parte successiva -------------- > > Un allegato HTML è stato rimosso... > > URL: < > http://lists.python.it/pipermail/python/attachments/20150807/52cf438f/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 4 > > Date: Fri, 7 Aug 2015 19:21:00 +0200 > > From: Manlio Perillo <manlio.peri...@gmail.com <javascript:;>> > > To: Discussioni generali sul linguaggio Python > > <python@lists.python.it <javascript:;>> > > Subject: Re: [Python] Mockare aiohttp per tests > > Message-ID: > > <CAAToxAGSnwhZ_KjuPGUtEZT1SG7Swd4ADyRMciZLSPQEn+LY=a...@mail.gmail.com > <javascript:;>> > > Content-Type: text/plain; charset="utf-8" > > > > 2015-08-07 18:41 GMT+02:00 flandero <fland...@gmail.com <javascript:;>>: > > > >> La cosa bella e' che lavorando con asyncio non avrei neanche bisogno di > >> multiprocessing e queues, > > > > Puoi anche lanciare il server HTTP all'interno dello stesso processo > usando > > un thread o asyncio ma hai comunque bisogno di un canale di > comunicazione. > > Come implementi tale canale è solo un dettaglio; una queue è la soluzione > > forse più semplice. > > > >> ma cosi' non si sconfina dal contesto test di unita' a quello dei test > di > >> interoperabilita'? > > > > Se hai un client HTTP e devi testare che la richiesta che fa è corretta, > > non vedo modo migliore di usare un server HTTP > > e verificare quello che viene ricevuto. > > > > Fare il mocking la vedo come ultima risorsa. > > > > > > Ciao Manlio > > -------------- parte successiva -------------- > > Un allegato HTML è stato rimosso... > > URL: < > http://lists.python.it/pipermail/python/attachments/20150807/e37ee24d/attachment-0001.html > > > > > > ------------------------------ > > > > Message: 5 > > Date: Fri, 7 Aug 2015 23:52:12 +0100 > > From: enrico franchi <enrico.fran...@gmail.com <javascript:;>> > > To: Discussioni generali sul linguaggio Python > > <python@lists.python.it <javascript:;>> > > Subject: Re: [Python] Mockare aiohttp per tests > > Message-ID: > > <ca+t0k1z3wmruak7pcm9olmqap7fzlegugh8tm35ajn8msa2...@mail.gmail.com > <javascript:;>> > > Content-Type: text/plain; charset="utf-8" > > > > 2015-08-07 18:21 GMT+01:00 Manlio Perillo <manlio.peri...@gmail.com > <javascript:;>>: > > > >> Se hai un client HTTP e devi testare che la richiesta che fa è corretta, > >> non vedo modo migliore di usare un server HTTP > >> e verificare quello che viene ricevuto. > >> > >> Fare il mocking la vedo come ultima risorsa. > > > > > > Sono due cose diverse. > > > > -- > > . > > ..: -enrico- > > -------------- parte successiva -------------- > > Un allegato HTML è stato rimosso... > > URL: < > http://lists.python.it/pipermail/python/attachments/20150807/f03a4c7f/attachment-0001.html > > > > > > ------------------------------ > > > > _______________________________________________ > > Python mailing list > > Python@lists.python.it <javascript:;> > > http://lists.python.it/mailman/listinfo/python > > > > > > Fine di Digest di Python, Volume 114, Numero 3 > > ********************************************** > _______________________________________________ > Python mailing list > Python@lists.python.it <javascript:;> > http://lists.python.it/mailman/listinfo/python > -- Simone Federici ------------------------ Software Craftsman XP, Agile, Scrum, Kanban Quality, performance & security Explicit is better than implicit.
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python