mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
add string unit tests
This commit is contained in:
parent
737ccf85c1
commit
fb1f397fee
3
Makefile
3
Makefile
@ -37,3 +37,6 @@ tar:
|
|||||||
# Create tagged archive
|
# Create tagged archive
|
||||||
git archive --format=tar --prefix autojump_v$(VERSION)/ $(TAGNAME) | gzip > autojump_v$(VERSION).tar.gz
|
git archive --format=tar --prefix autojump_v$(VERSION)/ $(TAGNAME) | gzip > autojump_v$(VERSION).tar.gz
|
||||||
sha1sum autojump_v$(VERSION).tar.gz
|
sha1sum autojump_v$(VERSION).tar.gz
|
||||||
|
|
||||||
|
test:
|
||||||
|
testify -v tests
|
||||||
|
@ -174,7 +174,7 @@ def print_tab_menu(needle, tab_entries, separator):
|
|||||||
|
|
||||||
|
|
||||||
def sanitize(directories):
|
def sanitize(directories):
|
||||||
clean = lambda x: decode(x).rstrip(os.sep)
|
clean = lambda x: decode(x) if len(x) == 1 else decode(x).rstrip(os.sep)
|
||||||
return list(imap(clean, directories))
|
return list(imap(clean, directories))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from testify import *
|
import mock
|
||||||
|
from testify import TestCase
|
||||||
|
from testify import assert_equal
|
||||||
|
from testify import run
|
||||||
|
|
||||||
|
import autojump_utils
|
||||||
from autojump_utils import decode
|
from autojump_utils import decode
|
||||||
from autojump_utils import first
|
from autojump_utils import first
|
||||||
from autojump_utils import second
|
|
||||||
from autojump_utils import last
|
from autojump_utils import last
|
||||||
|
from autojump_utils import sanitize
|
||||||
|
from autojump_utils import second
|
||||||
|
from autojump_utils import surround_quotes
|
||||||
from autojump_utils import take
|
from autojump_utils import take
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +20,18 @@ class StringTestCase(TestCase):
|
|||||||
assert_equal(decode(r'blah'), u'blah')
|
assert_equal(decode(r'blah'), u'blah')
|
||||||
assert_equal(decode(r'日本語'), u'日本語')
|
assert_equal(decode(r'日本語'), u'日本語')
|
||||||
|
|
||||||
|
@mock.patch.object(autojump_utils, 'in_bash', return_value=True)
|
||||||
|
def test_surround_quotes_in_bash(self, _):
|
||||||
|
assert_equal(surround_quotes('foo'), '"foo"')
|
||||||
|
|
||||||
|
@mock.patch.object(autojump_utils, 'in_bash', return_value=False)
|
||||||
|
def test_dont_surround_quotes_not_in_bash(self, _):
|
||||||
|
assert_equal(surround_quotes('foo'), 'foo')
|
||||||
|
|
||||||
|
def test_sanitize(self):
|
||||||
|
assert_equal(sanitize([]), [])
|
||||||
|
assert_equal(sanitize([r'/foo/bar/', r'/']), [u'/foo/bar', u'/'])
|
||||||
|
|
||||||
|
|
||||||
class IterationTestCase(TestCase):
|
class IterationTestCase(TestCase):
|
||||||
def test_first(self):
|
def test_first(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user