Created
March 8, 2012 20:36
-
-
Save minrk/2003276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7c8eb589a04813ca983d03be2976eaaf01d57481 Mon Sep 17 00:00:00 2001 | |
From: MinRK <benjaminrk@gmail.com> | |
Date: Thu, 8 Mar 2012 12:33:08 -0800 | |
Subject: [PATCH] test list_profiles functions | |
--- | |
IPython/core/tests/test_profile.py | 27 +++++++++++++++++++++++++++ | |
1 files changed, 27 insertions(+), 0 deletions(-) | |
diff --git a/IPython/core/tests/test_profile.py b/IPython/core/tests/test_profile.py | |
index d3bbfe7..8bcb125 100644 | |
--- a/IPython/core/tests/test_profile.py | |
+++ b/IPython/core/tests/test_profile.py | |
@@ -1,3 +1,4 @@ | |
+# coding: utf-8 | |
"""Tests for profile-related functions. | |
Currently only the startup-dir functionality is tested, but more tests should | |
@@ -29,6 +30,7 @@ import nose.tools as nt | |
from nose import SkipTest | |
from IPython.core.profiledir import ProfileDir | |
+from IPython.core.profileapp import list_bundled_profiles, list_profiles_in | |
from IPython.testing import decorators as dec | |
from IPython.testing import tools as tt | |
@@ -111,3 +113,28 @@ def test_startup_ipy(): | |
options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test']) | |
+def test_list_bundled_profiles(): | |
+ profiles = list_bundled_profiles() | |
+ nt.assert_equals(set(profiles), set(['cluster', 'math', 'pysh', 'python3', 'sympy'])) | |
+ | |
+def test_list_profiles_in(): | |
+ td = tempfile.mkdtemp(dir=TMP_TEST_DIR) | |
+ td = py3compat.str_to_unicode(td) | |
+ for name in ('profile_foo', u'profile_ünicode', 'profile_hello', 'not_a_profile'): | |
+ os.mkdir(os.path.join(td, name)) | |
+ with open(os.path.join(td, 'profile_file'), 'w') as f: | |
+ f.write("I am not a profile directory") | |
+ profiles = list_profiles_in(td) | |
+ | |
+ # unicode normalization can turn u'ünicode' into u'u\0308nicode', | |
+ # so only check for *nicode, and that creating a ProfileDir from the | |
+ # name remains valid | |
+ found_unicode = False | |
+ for p in list(profiles): | |
+ if p.endswith('nicode'): | |
+ pd = ProfileDir.find_profile_dir_by_name(td, p) | |
+ profiles.remove(p) | |
+ found_unicode=True | |
+ break | |
+ nt.assert_true(found_unicode) | |
+ nt.assert_equals(set(profiles), set(['foo', 'hello'])) | |
-- | |
1.7.5.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment