소스 검색

Fix random error in the pyramid tests.

Since python's randint is inclusive on both ends (unlike range()),
about one out of every 10,000 database queries with indices pulled
from random(1, 10001) would generate an internal server error.
This popped up occasionally when running the queries test with
a large parameter.
Joshua Maddux 10 년 전
부모
커밋
c622c8902a
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      frameworks/Python/pyramid/frameworkbenchmarks/views.py

+ 4 - 4
frameworks/Python/pyramid/frameworkbenchmarks/views.py

@@ -21,7 +21,7 @@ def test_2(request):
     """
     Test type 2: Single database query
     """
-    num = randint(1, 10001)
+    num = randint(1, 10000)
     result = DBSession.query(World).filter(World.id == num).one()
     return result
 
@@ -43,7 +43,7 @@ def test_3(request):
             queries = 500
     result = [
         DBSession.query(World).filter(World.id == num).one()
-        for num in [randint(1, 10001) for _ in range(1, queries + 1)]
+        for num in [randint(1, 10000) for _ in range(1, queries + 1)]
     ]
     return result
 
@@ -77,10 +77,10 @@ def test_5(request):
             queries = 500
     objset = [
         DBSession.query(World).filter(World.id == num).one()
-        for num in [randint(1, 10001) for _ in range(1, queries + 1)]
+        for num in [randint(1, 10000) for _ in range(1, queries + 1)]
     ]
     for obj in objset:
-        obj.randomNumber = randint(1, 10001)
+        obj.randomNumber = randint(1, 10000)
     resultset = [obj.__json__() for obj in objset]
     DBSession.commit()
     return resultset