summaryrefslogtreecommitdiff
path: root/framework/tests
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-11-20 15:44:48 -0800
committerDylan Baker <baker.dylan.c@gmail.com>2015-11-23 14:19:41 -0800
commit0d02210998539e581b3f90d1795c422234fe1eff (patch)
treee892d9ecfcacef09445dd3d53b15d6eff48780a8 /framework/tests
parent15c96c5821df9031ff992d5808a7d6eef78e7f2e (diff)
framework/grouptools.py: Add a function for print formatting
This adds a function to grouptools that replaces grouptools.SEPARATOR with '/'. This function is meant for use when printing to the console, since most people find '/' easier to read than whatever is being used internally to separate a group, and because consistence counts. The implementation differs from that originally used in console_.py, this implementation (tested on python 2.7.10) is roughly twice as fast. v2: - fix typos Reviewed-by Glenn Kennard <glenn.kennard@gmail.com> Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework/tests')
-rw-r--r--framework/tests/grouptools_tests.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/framework/tests/grouptools_tests.py b/framework/tests/grouptools_tests.py
index acab7ed43..36dd61cdc 100644
--- a/framework/tests/grouptools_tests.py
+++ b/framework/tests/grouptools_tests.py
@@ -28,7 +28,7 @@ import framework.grouptools as grouptools
import framework.tests.utils as utils
doc_formatter = utils.DocFormatter({ # pylint: disable=invalid-name
- 'seperator': grouptools.SEPARATOR,
+ 'separator': grouptools.SEPARATOR,
})
@@ -69,7 +69,7 @@ def test_grouptools_join():
@doc_formatter
def test_grouptools_join_notrail():
- """grouptools.join: doesn't add trailing {seperator} with empty element"""
+ """grouptools.join: doesn't add trailing {separator} with empty element"""
test = grouptools.join('g1', 'g2', '')
nt.ok_(not test.endswith(grouptools.SEPARATOR))
@@ -81,7 +81,7 @@ def test_split_input_empty():
@doc_formatter
def test_from_path_posix():
- """grouptools.from_path: converts / to {seperator} in posix paths."""
+ """grouptools.from_path: converts / to {separator} in posix paths."""
# Since we already have tests for grouptools.join we can trust it to do the
# right thing here. This also means that the test doesn't need to be
# updated if the separator is changed.
@@ -91,7 +91,7 @@ def test_from_path_posix():
@doc_formatter
def test_from_path_nt():
- """grouptools.from_path: converts \\ to {seperator} in nt paths."""
+ """grouptools.from_path: converts \\ to {separator} in nt paths."""
nt.assert_equal(grouptools.from_path('foo\\bar'),
grouptools.join('foo', 'bar'))
@@ -119,3 +119,10 @@ def test_join_empty():
def test_commonprefix_none():
"""grouptools.commonprefix: returns '' when no values are the same"""
nt.eq_('', grouptools.commonprefix(['foo', 'bar']))
+
+
+@doc_formatter
+def test_format():
+ """grouptools.format: replaces {separator} with '/'"""
+ test_str = grouptools.SEPARATOR.join(['foo', 'bar', 'boink'])
+ nt.eq_(grouptools.format(test_str), 'foo/bar/boink')