Very little error in test_datastore.py

Bug #618311 reported by Thibault Févry on 2010-08-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Getting Things GNOME!
Low
Thibault Févry

Bug Description

 [Running ./run_tests from repo]

This error won't happend all the time, actually just 1/20 of the time.

 Why this happens ?

 Because in the code, we have at a certain point this :

for temp in xrange(1, int(random.random() * 20)):
    backend.fake_add_random_task()

 The problem here is that if int(random.random() * 20) is 1. There will be no tasks.

[ Same behaviour as :

i = 0
while i < int(random()*2):
    print "1"

That will only print "1" once in every 2 runs.

This makes that 1/20 times, this test result isn't correct.

Also in the patch, I also made some other improvements in the code of that module. (Using randint(start, limit) instead of int(random.random()*limit) and removed 25 of 26 pep8 errors.

I also changed one time.sleep(5) to time.sleep(2), it's enough time. [This makes a 3s speedup when running the test suite.]

 Hope the patch looks fine, I'm not very good in publishing my work. (I don't use patches or bazaar very often.)

Related branches

Thibault Févry (thibaultfevry) wrote :

This is the patch generated by bzr, which don't preserve removing of spaces to be compliant with pep8.

[They were 26 errors, there's only 1 now.]

[The other little change isn't really import, also fixes one pep8 error.]

Changed in gtg:
assignee: nobody → Thibault Fevry (thibaultfevry)
description: updated
Changed in gtg:
status: New → In Progress
Luca Invernizzi (invernizzi) wrote :

Patch was perfect, thanks!

Changed in gtg:
status: In Progress → Fix Committed
importance: Undecided → Low
milestone: none → 0.3
Changed in gtg:
milestone: 0.3 → 0.2.9
Izidor Matušov (izidor) on 2012-02-13
Changed in gtg:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments