コード例 #1
0
ファイル: test_util.py プロジェクト: smarketplaces/cleaver
    def test_generally_random(self):
        items = ('True', 'False')
        weights = (1, 1)
        results = {}
        total = 50000

        for _ in range(total):
            v = next(random_variant(items, weights))
            results.setdefault(v, 0)
            results[v] += 1

        a = results['True'] / float(total)
        b = results['False'] / float(total)
        assert a > .49 and a < .51
        assert b > .49 and b < .51
コード例 #2
0
ファイル: test_util.py プロジェクト: ryanpetrello/cleaver
    def test_generally_random(self):
        items = ("True", "False")
        weights = (1, 1)
        results = {}
        total = 50000

        for _ in range(total):
            v = next(random_variant(items, weights))
            results.setdefault(v, 0)
            results[v] += 1

        a = results["True"] / float(total)
        b = results["False"] / float(total)
        assert a > 0.49 and a < 0.51
        assert b > 0.49 and b < 0.51
コード例 #3
0
ファイル: test_util.py プロジェクト: smarketplaces/cleaver
    def test_generally_random_with_weights(self):
        items = ('A', 'B', 'C')
        weights = (1, 3, 6)
        results = {}
        total = 50000

        for _ in range(total):
            v = next(random_variant(items, weights))
            results.setdefault(v, 0)
            results[v] += 1

        a = results['A'] / float(total)
        b = results['B'] / float(total)
        c = results['C'] / float(total)
        assert a > .09 and a < .11
        assert b > .29 and b < .31
        assert c > .59 and c < .61
コード例 #4
0
ファイル: test_util.py プロジェクト: ryanpetrello/cleaver
    def test_generally_random_with_weights(self):
        items = ("A", "B", "C")
        weights = (1, 3, 6)
        results = {}
        total = 50000

        for _ in range(total):
            v = next(random_variant(items, weights))
            results.setdefault(v, 0)
            results[v] += 1

        a = results["A"] / float(total)
        b = results["B"] / float(total)
        c = results["C"] / float(total)
        assert a > 0.09 and a < 0.11
        assert b > 0.29 and b < 0.31
        assert c > 0.59 and c < 0.61
コード例 #5
0
ファイル: test_stack.py プロジェクト: ryanpetrello/cleaver
 def app(environ, start_response):
     response_headers = [('Content-type', 'text/plain')]
     start_response('200 OK', response_headers)
     return next(handler)(environ)
コード例 #6
0
 def app(environ, start_response):
     response_headers = [('Content-type', 'text/plain')]
     start_response('200 OK', response_headers)
     return next(handler)(environ)