[Django] #20514: django.contrib.gis.tests.test_measure.{AreaTest, DistanceTest} fail in py3

6 views
Skip to first unread message

Django

unread,
May 27, 2013, 1:32:10 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-----------------------------------+--------------------
Reporter: idella4 | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.5
Severity: Normal | Keywords: tests
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+--------------------
PYTHONPATH=.:../Django-1.5.1-python3_2/lib/:../Django-1.5.1-python3_2/
python tests/runtests.py --settings=test_sqlite -v1

{{{
.......ss.sE........E.........ssssssss..................
======================================================================
ERROR: testAccess (django.contrib.gis.tests.test_measure.AreaTest)
Testing access in different units
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/tmp/portage/portage/dev-
python/django-1.5.1/work/Django-1.5.1/django/contrib/gis/tests/test_measure.py",
line 175, in testAccess
self.assertAlmostEqual(a.sq_ft, 1076.391, 3)
TypeError: assertAlmostEqual() takes exactly 3 positional arguments (4
given)

======================================================================
ERROR: testAccess (django.contrib.gis.tests.test_measure.DistanceTest)
Testing access in different units
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/tmp/portage/portage/dev-
python/django-1.5.1/work/Django-1.5.1/django/contrib/gis/tests/test_measure.py",
line 43, in testAccess
self.assertAlmostEqual(d.ft, 328.084, 3)
TypeError: assertAlmostEqual() takes exactly 3 positional arguments (4
given)

----------------------------------------------------------------------
Ran 4963 tests in 855.328s

FAILED (errors=2, skipped=175, expected failures=4)
}}}

(a.sq_ft, 1076.391, 3)
(d.ft, 328.084, 3)

Well I count 3 positional arguments, py3 counts 4 given.
tilt.
py3 can't count??

--
Ticket URL: <https://code.djangoproject.com/ticket/20514>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 27, 2013, 1:39:37 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-----------------------------------+--------------------------------------

Reporter: idella4 | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.5
Severity: Normal | Resolution:

Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by idella4):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:1>

Django

unread,
May 27, 2013, 2:05:22 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody
Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo

Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------
Changes (by bmispelon):

* cc: bmispelon@… (added)
* resolution: => needsinfo
* status: new => closed
* component: Testing framework => GIS
* easy: 1 => 0


Comment:

Hi,

I can't reproduce the issue (using python 3.3 here). I tried running the
`contrib.gis` tests on `master`, on `stable/1.5.x` and on the `1.5.1` tag
too and they all pass.

I think your setup may be at fault here (this would have been caught by
our CI server too). Can you try running the tests in a clean environment?
Do you have a strange version of `unittest` on your path maybe?

I'm marking this as `needsinfo` for now. Please reopen when you have more
info on how to reproduce the issue.

Thanks

PS: The "wrong" argument count comes from the fact that python
automatically passes the instance (`self`) as a first parameter when
calling a method.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:2>

Django

unread,
May 27, 2013, 2:06:22 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by charettes):

`self` is the first positional argument here.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:3>

Django

unread,
May 27, 2013, 2:16:40 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by claudep):

Exact Python version might help, too.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:4>

Django

unread,
May 27, 2013, 3:12:58 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

it was py3.2.3. Hopefully I just need 3.2.4

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:5>

Django

unread,
May 27, 2013, 3:20:30 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

I only run tests in a clean environment. An ebuild deletes the source code
on each run.

Is PYTHONPATH=. python3.2 tests/runtests.py --settings=test_sqlite -v1 the
best or most apt way to run the test suite?

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:6>

Django

unread,
May 27, 2013, 3:30:47 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by bmispelon):

> Is PYTHONPATH=. python3.2 tests/runtests.py --settings=test_sqlite -v1
the best or most apt way to run the test suite?

That should work, yes. AFAIK, the recommended way is
`PYTHONPATH=..:$PYTHONPATH python ./runtests.py --settings=test_sqlite`
(run from the `tests` directory) [1]

I'll try to get my hands on a 3.2 build to see if I can trigger the issue
too.

Have you tried running the full test suite as well?
I checked and `assertAlmostEqual` is also used in the `modeltests` tests.
Do those fail too?

[1] https://docs.djangoproject.com/en/dev/internals/contributing/writing-
code/unit-tests/#quickstart

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:7>

Django

unread,
May 27, 2013, 3:47:31 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

bmispelon , eeer the full testsuite? I thought I had. What am I missing??

On there-run both py3.2.4 and 3.3.0 failed on them again. So this is from
the ebuild simply unpacking the source, cd into it and running the
testsuite without any building so if that's not clean I don't know what
is. You say that py counts the self so why is the tally then not 4???
I'm running it again from cd into tests and PYTHONPATH=..:$PYTHONPATH
python ./runtests.py --settings=test_sqlite which ought be the same.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:8>

Django

unread,
May 27, 2013, 3:55:03 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

I'm guessing I've run the whole suite, it takes about 15 minutes, those
couple of fails occur right at the end, so I'm guessing any modeltests are
run and pass. If there were anything else fail I'd have entered it

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:9>

Django

unread,
May 27, 2013, 4:44:16 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by claudep):

Are you really using CPython? Using positional arguments to pass
parameters to a method with mixed positional/keyword arguments is
explicitely admitted (see
http://docs.python.org/3.2/tutorial/controlflow.html#keyword-arguments).
And as you are the first to signal this error, something must be special
on your side.

See also assertAlmostEqual definition:
http://hg.python.org/cpython/file/687295c6c8f2/Lib/unittest/case.py#l527

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:10>

Django

unread,
May 27, 2013, 5:19:51 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

hmm well this
{{{
======================================================================
FAIL: testAccess (django.contrib.gis.tests.test_measure.AreaTest)


Testing access in different units
----------------------------------------------------------------------
Traceback (most recent call last):

File "/mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/django/contrib/gis/tests/test_measure.py",
line 175, in testAccess
self.assertAlmostEqual(a.sq_ft, 1076.391)
AssertionError: 1076.391041670972 != 1076.391 within 7 places

======================================================================
FAIL: testAccess (django.contrib.gis.tests.test_measure.DistanceTest)


Testing access in different units
----------------------------------------------------------------------
Traceback (most recent call last):

File "/mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/django/contrib/gis/tests/test_measure.py",
line 43, in testAccess
self.assertAlmostEqual(d.ft, 328.084)
AssertionError: 328.0839895013123 != 328.084 within 7 places

----------------------------------------------------------------------
}}}

resulted from taking out the last arg (3) out of the two instances of
self.assertAlmostEqual.
The 7 default comes into play. The absence of the , 3 indeed took away the
<takes exactly 3 positional arguments (4 given)> error.

But why only me? Am I using CPython?. Well I'm not using pypy and I think
that only leaves cpython.
I'm re-running it again with what makes sense to me to get it to pass.

self.assertAlmostEqual(a.sq_ft, 1076.391, places=3)

The self I don't know offhand how to exclude without breaking.
The places= being an optional ought be honoured, making for 2 args and 1
optional, no?
My system is just a run o' the mill gentoo python developer system, with
all 6 pythons and 3 pypys emerged.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:11>

Django

unread,
May 27, 2013, 5:23:37 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

----------------------------------------------------------------------
Ran 4963 tests in 883.139s

OK (skipped=177, expected failures=4)
Destroying test database for alias 'default'...

that would be a yes

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:12>

Django

unread,
May 27, 2013, 5:45:57 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------
Changes (by Ian Delaney <della5@…>):

* has_patch: 0 => 1


Comment:

diff -ur Django-1.5.orig/django/contrib/gis/tests/test_measure.py
Django-1.5/django/contrib/gis/tests/test_measure.py
--- django/contrib/gis/tests/test_measure.py 2013-02-27
03:04:14.000000000 +0800
+++ django/contrib/gis/tests/test_measure.py 2013-05-28
04:40:18.983011224 +0800
@@ -40,7 +40,7 @@


"Testing access in different units"

d = D(m=100)
self.assertEqual(d.km, 0.1)
- self.assertAlmostEqual(d.ft, 328.084, 3)
+ self.assertAlmostEqual(d.ft, 328.084, places=3)

def testAccessInvalid(self):
"Testing access in invalid units"
@@ -172,7 +172,7 @@


"Testing access in different units"

a = A(sq_m=100)
self.assertEqual(a.sq_km, 0.0001)
- self.assertAlmostEqual(a.sq_ft, 1076.391, 3)
+ self.assertAlmostEqual(a.sq_ft, 1076.391, places=3)

def testAccessInvaliA(self):
"Testing access in invalid units"

this works for me, hope you find it appliccable

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:13>

Django

unread,
May 27, 2013, 6:02:32 PM5/27/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

see there

{{{
testuser@archtester ~/cvsPortage/gentoo-x86/dev-python/django $ grep
AlmostEqual -r /mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/tests/modeltests/
/mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/tests/modeltests/aggregation/tests.py:
self.assertAlmostEqual(vals["friends__age__avg"], 34.07, places=2)
/mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/tests/modeltests/aggregation/tests.py:
self.assertAlmostEqual(vals["authors__age__avg"], 38.2857, places=2)
/mnt/gen2/TmpDir/portage/dev-
python/django-1.5-r1/work/Django-1.5/tests/modeltests/aggregation/tests.py:
self.assertAlmostEqual(vals["amazon_mean"], 4.08, places=2)
}}}

, places= is used in all 3 instances, and they all passed for me

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:14>

Django

unread,
May 28, 2013, 3:04:46 AM5/28/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: tests | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

I'm totally miffed by why yours passes under py3 and mine doesn't. There
must be something 'special on my side' logically. Any guesses? I got
nothing.
The adding of places= simply makes the code consistent between tests. I
won't re-open this since that really needs pinning that special quality,
however the patch won't break anything and will make for consistency. I've
added the patch to the 1.5 versions in portage.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:15>

Django

unread,
May 28, 2013, 3:06:50 AM5/28/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: invalid

Keywords: tests | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------
Changes (by claudep):

* resolution: needsinfo => invalid


Comment:

I think I found the bug: http://bugs.python.org/issue10353

Now the question is for you why you are still affected by this bug fixed
some time ago. Either some older Python installation is left somewhere on
your system, or a very recent Python commit reinstated this bug. In any
case, this is not Django's fault, as `self.assertAlmostEqual(a.sq_ft,
1076.391, places=3)` or `self.assertAlmostEqual(a.sq_ft, 1076.391, 3)`
are strictly equivalent.

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:16>

Django

unread,
May 28, 2013, 3:53:14 AM5/28/13
to django-...@googlegroups.com
#20514: django.contrib.gis.tests.test_measure.{AreaTest,DistanceTest} fail in py3
-------------------------+--------------------------------------
Reporter: idella4 | Owner: nobody

Type: Bug | Status: closed
Component: GIS | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: tests | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+--------------------------------------

Comment (by Ian Delaney <della5@…>):

right. well my python installs are recent and current, sp I'd go for
something re-instating it. I'll see if some other python devs have some
idea. thx

--
Ticket URL: <https://code.djangoproject.com/ticket/20514#comment:17>

Reply all
Reply to author
Forward
0 new messages