Skip to content

Commit

Permalink
Merge pull request #271 from lotabout/fix-tests
Browse files Browse the repository at this point in the history
fix tests of case folding on Linux
  • Loading branch information
lotabout authored Feb 23, 2020
2 parents 7223980 + 9a826ef commit 4f391e1
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions test/test_skim.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def matcher_stopped(self):
def ready_with_lines(self, lines):
return self.item_count() == lines and self.matcher_stopped()

def ready_with_matches(self, matches):
return self.match_count() == matches and self.matcher_stopped()

def any_include(self, val):
if hasattr(re, '_pattern_type') and isinstance(val, re._pattern_type):
method = lambda l: val.match(l)
Expand Down Expand Up @@ -712,13 +715,11 @@ def test_smart_case_fuzzy(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key('aBc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key('ABc'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())
self.tmux.until(lambda lines: lines.ready_with_matches(0))

def test_smart_case_exact(self):
"""should behave correctly on case, #219"""
Expand All @@ -727,13 +728,11 @@ def test_smart_case_exact(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key("'aBc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key("'ABc"))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())
self.tmux.until(lambda lines: lines.ready_with_matches(0))

def test_ignore_case_fuzzy(self):
"""should behave correctly on case, #219"""
Expand All @@ -742,12 +741,11 @@ def test_ignore_case_fuzzy(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case ignore')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key('aBc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key('ABc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))

def test_ignore_case_exact(self):
"""should behave correctly on case, #219"""
Expand All @@ -756,12 +754,11 @@ def test_ignore_case_exact(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case ignore')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key("'aBc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))
self.tmux.send_keys(Ctrl('u'), Key("'ABc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_matches(1))

def test_respect_case_fuzzy(self):
"""should behave correctly on case, #219"""
Expand All @@ -770,9 +767,7 @@ def test_respect_case_fuzzy(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case respect')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())
self.tmux.until(lambda lines: lines.ready_with_matches(0))

def test_respect_case_exact(self):
"""should behave correctly on case, #219"""
Expand All @@ -781,9 +776,7 @@ def test_respect_case_exact(self):
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case respect')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())
self.tmux.until(lambda lines: lines.ready_with_matches(0))

def find_prompt(lines, interactive=False, reverse=False):
linen = -1
Expand Down

0 comments on commit 4f391e1

Please sign in to comment.