mirror of
https://github.com/wting/autojump
synced 2026-03-02 03:49:26 +00:00
add string unit tests
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- 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 first
|
||||
from autojump_utils import second
|
||||
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
|
||||
|
||||
|
||||
@@ -14,6 +20,18 @@ class StringTestCase(TestCase):
|
||||
assert_equal(decode(r'blah'), u'blah')
|
||||
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):
|
||||
def test_first(self):
|
||||
|
||||
Reference in New Issue
Block a user