Skip to content

Commit d2eb5ec

Browse files
committed
wip: gremlins and hypothesis
1 parent cc4b7de commit d2eb5ec

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ setuptools-*.egg
1717
cogapp.egg-info
1818
.tox
1919
.*cache
20+
.hypothesis/
2021

2122
docs/_build

cogapp/test_whiteutils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from unittest import TestCase
44

5+
import hypothesis
6+
import hypothesis.strategies as st
7+
58
from .whiteutils import common_prefix, reindent_block, white_prefix
69

710

@@ -94,3 +97,13 @@ def test_blank_line(self):
9497

9598
def test_decreasing_lengths(self):
9699
self.assertEqual(common_prefix(["abcd", "abc", "ab"]), "ab")
100+
101+
102+
@hypothesis.given(st.lists(st.text(max_size=100), max_size=50))
103+
# @hypothesis.settings(max_examples=1_000_000)
104+
def test_common_prefix(strings):
105+
"""Test that common_prefix returns a prefix of all the strings."""
106+
prefix = common_prefix(strings)
107+
assert all(s.startswith(prefix) for s in strings)
108+
if len(set(strings)) > 1:
109+
assert len(set(s[: len(prefix) + 1] for s in strings)) > 1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ version.attr = "cogapp.cogapp.__version__"
4343
[build-system]
4444
requires = ["setuptools>=80"]
4545
build-backend = "setuptools.build_meta"
46+
47+
[tool.pytest-gremlins]
48+
paths = ["cogapp"]

0 commit comments

Comments
 (0)