8000 Remove myunit by elazarg · Pull Request #4369 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Remove myunit #4369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 6, 2018
Prev Previous commit
Next Next commit
remove unused helpers
  • Loading branch information
elazarg committed Dec 15, 2017
commit ca12acf2454e48513d3189d92ea3fbc3c68bcb0c
71 changes: 0 additions & 71 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,6 @@ def show_align_message(s1: str, s2: str) -> None:
sys.stderr.write('\n')


def assert_string_arrays_equal_wildcards(expected: List[str],
actual: List[str],
msg: str) -> None:
# Like above, but let a line with only '...' in expected match any number
# of lines in actual.
actual = clean_up(actual)

while actual != [] and actual[-1] == '':
actual = actual[:-1]

# Expand "..." wildcards away.
expected = match_array(expected, actual)
assert_string_arrays_equal(expected, actual, msg)


def clean_up(a: List[str]) -> List[str]:
"""Remove common directory prefix from all strings in a.

Expand All @@ -205,52 +190,6 @@ def clean_up(a: List[str]) -> List[str]:
return res


def match_array(pattern: List[str], target: List[str]) -> List[str]:
"""Expand '...' wildcards in pattern by matching against target."""

res = [] # type: List[str]
i = 0
j = 0

while i < len(pattern):
if pattern[i] == '...':
# Wildcard in pattern.
if i + 1 == len(pattern):
# Wildcard at end of pattern; match the rest of target.
res.extend(target[j:])
# Finished.
break
else:
# Must find the instance of the next pattern line in target.
jj = j
while jj < len(target):
if target[jj] == pattern[i + 1]:
break
jj += 1
if jj == len(target):
# No match. Get out.
res.extend(pattern[i:])
break
res.extend(target[j:jj])
i += 1
j = jj
elif (j < len(target) and (pattern[i] == target[j]
or (i + 1 < len(pattern)
and j + 1 < len(target)
and pattern[i + 1] == target[j + 1]))):
# In sync; advance one line. The above condition keeps sync also if
# only a single line is different, but loses it if two consecutive
# lines fail to match.
res.append(pattern[i])
i += 1
j += 1
else:
# Out of sync. Get out.
res.extend(pattern[i:])
break
return res


def num_skipped_prefix_lines(a1: List[str], a2: List[str]) -> int:
num_eq = 0
while num_eq < min(len(a1), len(a2)) and a1[num_eq] == a2[num_eq]:
Expand Down Expand Up @@ -321,11 +260,6 @@ def __init__(self, s: Optional[str] = None) -> None:
super().__init__()


class SkipTestCaseException(Exception):
"""Exception used to signal skipped test cases."""
pass


def assert_true(b: bool, msg: Optional[str] = None) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment about assert_true and assert_false being redundant (we could just use the assert statement).

if not b:
raise AssertionFailure(msg)
Expand Down Expand Up @@ -353,11 +287,6 @@ def assert_equal(a: object, b: object, fmt: str = '{} != {}') -> None:
raise AssertionFailure(fmt.format(good_repr(a), good_repr(b)))


def assert_not_equal(a: object, b: object, fmt: str = '{} == {}') -> None:
if a == b:
raise AssertionFailure(fmt.format(good_repr(a), good_repr(b)))


def typename(t: type) -> str:
if '.' in str(t):
return str(t).split('.')[-1].rstrip("'>")
Expand Down
0