Skip to content

Commit 81afacb

Browse files
committed
Move validate branch check back into scripts
1 parent fee6070 commit 81afacb

File tree

3 files changed

+65
-45
lines changed

3 files changed

+65
-45
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# coding=utf-8
2+
#
3+
# This file is part of Hypothesis, which may be found at
4+
# https://github.com/HypothesisWorks/hypothesis-python
5+
#
6+
# Most of this work is copyright (C) 2013-2018 David R. MacIver
7+
# (david@drmaciver.com), but it contains contributions by others. See
8+
# CONTRIBUTING.rst for a full list of people who may hold copyright, and
9+
# consult the git log if you need to determine who owns an individual
10+
# contribution.
11+
#
12+
# This Source Code Form is subject to the terms of the Mozilla Public License,
13+
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
14+
# obtain one at http://mozilla.org/MPL/2.0/.
15+
#
16+
# END HEADER
17+
18+
from __future__ import division, print_function, absolute_import
19+
20+
import sys
21+
import json
22+
from collections import defaultdict
23+
24+
if __name__ == '__main__':
25+
with open('branch-check') as i:
26+
data = [
27+
json.loads(l) for l in i
28+
]
29+
30+
checks = defaultdict(set)
31+
32+
for d in data:
33+
checks[d['name']].add(d['value'])
34+
35+
always_true = []
36+
always_false = []
37+
38+
for c, vs in sorted(checks.items()):
39+
if len(vs) < 2:
40+
v = list(vs)[0]
41+
assert v in (False, True)
42+
if v:
43+
always_true.append(c)
44+
else:
45+
always_false.append(c)
46+
47+
failure = always_true or always_false
48+
49+
if failure:
50+
print('Some branches were not properly covered.')
51+
print()
52+
53+
if always_true:
54+
print('The following were always True:')
55+
print()
56+
for c in always_true:
57+
print(' * %s' % (c,))
58+
if always_false:
59+
print('The following were always False:')
60+
print()
61+
for c in always_false:
62+
print(' * %s' % (c,))
63+
if failure:
64+
sys.exit(1)

hypothesis-python/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ commands =
146146
python -m coverage debug sys
147147
python -m coverage run --rcfile=.coveragerc -m pytest -n0 --strict tests/cover tests/datetime tests/py3 tests/numpy tests/pandas --maxfail=1 --ff {posargs}
148148
python -m coverage report -m --fail-under=100 --show-missing
149-
python ../scripts/validate_branch_check.py
149+
python ./scripts/validate_branch_check.py
150150

151151

152152
[testenv:pure-tracer]

tooling/src/hypothesistooling/__main__.py

-44
Original file line numberDiff line numberDiff line change
@@ -65,50 +65,6 @@ def check_pyup_yml():
6565
sys.exit(1)
6666

6767

68-
@task
69-
def validate_branch_check():
70-
with open('branch-check') as i:
71-
data = [
72-
json.loads(l) for l in i
73-
]
74-
75-
checks = defaultdict(set)
76-
77-
for d in data:
78-
checks[d['name']].add(d['value'])
79-
80-
always_true = []
81-
always_false = []
82-
83-
for c, vs in sorted(checks.items()):
84-
if len(vs) < 2:
85-
v = list(vs)[0]
86-
assert v in (False, True)
87-
if v:
88-
always_true.append(c)
89-
else:
90-
always_false.append(c)
91-
92-
failure = always_true or always_false
93-
94-
if failure:
95-
print('Some branches were not properly covered.')
96-
print()
97-
98-
if always_true:
99-
print('The following were always True:')
100-
print()
101-
for c in always_true:
102-
print(' * %s' % (c,))
103-
if always_false:
104-
print('The following were always False:')
105-
print()
106-
for c in always_false:
107-
print(' * %s' % (c,))
108-
if failure:
109-
sys.exit(1)
110-
111-
11268
DIST = os.path.join(tools.HYPOTHESIS_PYTHON, 'dist')
11369
PENDING_STATUS = ('started', 'created')
11470

0 commit comments

Comments
 (0)