Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (26 sloc) 834 Bytes
"""
Unit tests for statistics.
"""
import unittest
from pyqcy import *
class Statistics(unittest.TestCase):
"""Test cases for statistics functionality."""
def test_collect(self):
results = sorting_short_lists.check()
assert all(len(r.tags) > 0 for r in results)
def test_classify(self):
results = sort_preserves_length.check()
assert any(len(r.tags) > 0 for r in results)
# Test properties
@qc
def sorting_short_lists(
l=list_(float, min_length=1, max_length=6)
):
yield collect(len(l))
assert list(sorted(l))[-1] == max(l)
@qc
def sort_preserves_length(l=list_(int, max_length=64)):
yield classify(len(l) == 0, "empty list")
yield classify(len(l) % 2 == 0, "even list")
yield classify(len(l) % 2 != 0, "odd list")
assert len(list(sorted(l))) == len(l)
Something went wrong with that request. Please try again.