django-sane-testing doesn't start live server

37 views
Skip to first unread message

demalexx

unread,
Dec 26, 2010, 8:02:22 AM12/26/10
to Django: sane testing
Hi,

I'd like to run Selenium tests on CI server so I need running live
server before run tests. I subclass HttpTestCase, write some tests
using Selenium, then I do like here
http://devel.almad.net/docs/django-sane-testing/usage.html#running-tests:

set DJANGO_SETTINGS_MODULE=settings_test
set PYTHONPATH=.
nosetests myapp.tests:MyHttpTestCase --with-django

Seems it's creating DB, then it connects to Selenium and run FF (I see
that two FF windows). But then it fails, saying it can't connect. I
suppose this is because it didn't start developer server.

Almad

unread,
Dec 26, 2010, 5:32:40 PM12/26/10
to Django: sane testing
Hi,

On Dec 26, 2:02 pm, demalexx <demal...@gmail.com> wrote:
> Hi,
>
> I'd like to run Selenium tests on CI server so I need running live
> server before run tests. I subclass HttpTestCase, write some tests
> using Selenium, then I do like herehttp://devel.almad.net/docs/django-sane-testing/usage.html#running-te...

Docs are probably unclear there. I'll update them.


> set DJANGO_SETTINGS_MODULE=settings_test
> set PYTHONPATH=.
> nosetests myapp.tests:MyHttpTestCase --with-django
> I suppose this is because it didn't start developer server.

--with-django only starts integration plugin. To start development
server, You have to add --with-djangoliveserver (or --with-
cherrypyliveserver) and to support Selenium test cases, You have to
also add --with-selenium .

> Seems it's creating DB, then it connects to Selenium and run FF (I see
> that two FF windows).

This is strange, as when server/selenium plugin is not available, test
should skip itself. Are You inheriting from SelenimTestCase, or have
proper attributes on particular testcase set, as described in
http://devel.almad.net/docs/django-sane-testing/usage.html#writing-tests
?

HTH,

Almad

demalexx

unread,
Dec 27, 2010, 6:28:30 AM12/27/10
to Django: sane testing
Thanks for answering!

On Dec 27, 6:32 am, Almad <b...@almad.net> wrote:
> Hi,
>
> On Dec 26, 2:02 pm, demalexx <demal...@gmail.com> wrote:
>
> > Hi,
>
> > I'd like to run Selenium tests on CI server so I need running live
> > server before run tests. I subclass HttpTestCase, write some tests
> > using Selenium, then I do like herehttp://devel.almad.net/docs/django-sane-testing/usage.html#running-te...
>
> Docs are probably unclear there. I'll update them.
>
> > set DJANGO_SETTINGS_MODULE=settings_test
> > set PYTHONPATH=.
> > nosetests myapp.tests:MyHttpTestCase --with-django
> > I suppose this is because it didn't start developer server.
>
>  --with-django only starts integration plugin. To start development
> server, You have to add --with-djangoliveserver (or --with-
> cherrypyliveserver) and to support Selenium test cases, You have to
> also add --with-selenium .

Ok, that partially works - server is running now. But I constantly get
error: [Errno 10035]. Not on every request, but pretty often.

Traceback (most recent call last):
File "D:\programs\Python27\lib\SocketServer.py", line 582, in
process_request_thread
self.finish_request(request, client_address)
File "D:\programs\Python27\lib\SocketServer.py", line 323, in
finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\programs\Python27\lib\site-packages\django\core\servers
\basehttp.py", line 562, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "D:\programs\Python27\lib\SocketServer.py", line 639, in
__init__
self.handle()
File "D:\programs\Python27\lib\site-packages\django\core\servers
\basehttp.py", line 602, in handle
self.raw_requestline = self.rfile.readline()
File "D:\programs\Python27\lib\socket.py", line 445, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10035]

Never faced this error before on dev Django server... Seems because of
that error tests couldn't pass - they couldn't get responses. My env
is Windows 7, Python 2.7.

> > Seems it's creating DB, then it connects to Selenium and run FF (I see
> > that two FF windows).
>
> This is strange, as when server/selenium plugin is not available, test
> should skip itself. Are You inheriting from SelenimTestCase, or have
> proper attributes on particular testcase set, as described inhttp://devel.almad.net/docs/django-sane-testing/usage.html#writing-tests
> ?

I run Selenium manually and also use selenium.py that is inside
project folder. Will it work fine?

Almad

unread,
Dec 27, 2010, 7:38:08 AM12/27/10
to django-sa...@googlegroups.com
>>  --with-django only starts integration plugin. To start development
>> server, You have to add --with-djangoliveserver (or --with-
>> cherrypyliveserver) and to support Selenium test cases, You have to
>> also add --with-selenium .
> error: [Errno 10035]

My first try would be to install CherryPy and try
--with-cherrypyliveserver instead of liveserver.

> I run Selenium manually and also use selenium.py that is inside
> project folder. Will it work fine?

Well it's not designed to be used this way; it You use external
testing library, why not just start devserver and use non-destructive
gathering methods to run selenium suite?

The way DST is designed is to be part of the testsuite and use the
ability to have clean environment for every testcase etc.

Also, server is started lazily when first HTTP test is encountered.

Almad

demalexx

unread,
Jan 2, 2011, 6:55:25 AM1/2/11
to Django: sane testing
On Dec 27 2010, 8:38 pm, Almad <b...@almad.net> wrote:
> >>  --with-django only starts integration plugin. To start development
> >> server, You have to add --with-djangoliveserver (or --with-
> >> cherrypyliveserver) and to support Selenium test cases, You have to
> >> also add --with-selenium .
> > error: [Errno 10035]
>
> My first try would be to install CherryPy and try
> --with-cherrypyliveserver instead of liveserver.

Thanks, I'll try.

> > I run Selenium manually and also use selenium.py that is inside
> > project folder. Will it work fine?
>
> Well it's not designed to be used this way; it You use external
> testing library, why not just start devserver and use non-destructive
> gathering methods to run selenium suite?
>
> The way DST is designed is to be part of the testsuite and use the
> ability to have clean environment for every testcase etc.
>
> Also, server is started lazily when first HTTP test is encountered.

I had some problems with running test server and tests manually: when
started, test server creates test db to work with (manage.py
testserver); then when tests started (manage.py test), then same test
db is first destroyed, then recreated. Then when first test is
complete, data remains in db. So next test, assuming db is in initial
state, fails.

I suppose there is something I miss about running tests. I hoped DST
will solve my problem :)

Almad

unread,
Jan 2, 2011, 8:03:17 AM1/2/11
to django-sa...@googlegroups.com
On Sunday 02 of January 2011 12:55:25 demalexx wrote:
> I had some problems with running test server and tests manually: when
> started, test server creates test db to work with (manage.py
> testserver); then when tests started (manage.py test), then same test
> db is first destroyed, then recreated. Then when first test is
> complete, data remains in db. So next test, assuming db is in initial
> state, fails.

Yes. You can hack around by longer tests that do not require "initial"
state...but it's ugly.

> I suppose there is something I miss about running tests. I hoped DST
> will solve my problem :)

If Your tests are requiring initial state, they sound like proper testcases
and DST should help ;) However, I see no reason why they should not be part of
Your test suite.

Would You mind posting some test-case samples? It usually helps a lot ;)

Almad

demalexx

unread,
Jan 3, 2011, 8:26:04 AM1/3/11
to Django: sane testing
Hi,

I tried CherryPy and seems my tests are working now. But they run very
long, this is expected because of recreation of DB.

Thank you very much for help! I've asked this questions in several
places - no answers there.

Almad

unread,
Jan 3, 2011, 1:39:25 PM1/3/11
to django-sa...@googlegroups.com
On Monday 03 of January 2011 14:26:04 demalexx wrote:
> Hi,
>
> I tried CherryPy and seems my tests are working now. But they run very
> long, this is expected because of recreation of DB.

Well, this is the reason why it might be a good idea to split Your suite into
unit test and integration tests.

I use to run only specific integration tests I develop and leave the whole job
to CI server.

Alternatively, during development, You might want to use test selection
plugin: http://devel.almad.net/docs/django-sane-testing/usage.html#sane-test-
selection-plugin



> Thank you very much for help! I've asked this questions in several
> places - no answers there.

No problem, hope it helped :)

Almad

demalexx

unread,
Jan 4, 2011, 5:18:03 AM1/4/11
to Django: sane testing
On Jan 4, 2:39 am, Almad <b...@almad.net> wrote:
> On Monday 03 of January 2011 14:26:04 demalexx wrote:
>
> > Hi,
>
> > I tried CherryPy and seems my tests are working now. But they run very
> > long, this is expected because of recreation of DB.
>
> Well, this is the reason why it might be a good idea to split Your suite into
> unit test and integration tests.

Yes, tests in our project could be improved more, I hope sometime
we'll have separate tester who'll do all that stuff :)

> I use to run only specific integration tests I develop and leave the whole job
> to CI server.
>
> Alternatively, during development, You might want to use test selection
> plugin:http://devel.almad.net/docs/django-sane-testing/usage.html#sane-test-
> selection-plugin

Yes, good way - run all tests on CI server, while running only needed
tests on local machine.

> > Thank you very much for help! I've asked this questions in several
> > places - no answers there.
>
> No problem, hope it helped :)

Sure, thanks again :)
Reply all
Reply to author
Forward
0 new messages