1
0
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:
William Ting
2013-12-31 16:34:35 -06:00
parent 737ccf85c1
commit fb1f397fee
3 changed files with 24 additions and 3 deletions

View File

@@ -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):