##// END OF EJS Templates
Add improved test with unicode checks, by Min.
Fernando Perez -
Show More
@@ -1,3 +1,4 b''
1 # coding: utf-8
1 """Tests for profile-related functions.
2 """Tests for profile-related functions.
2
3
3 Currently only the startup-dir functionality is tested, but more tests should
4 Currently only the startup-dir functionality is tested, but more tests should
@@ -120,18 +121,31 b' class ProfileStartupTest(TestCase):'
120 def test_list_profiles_in():
121 def test_list_profiles_in():
121 # No need to remove these directories and files, as they will get nuked in
122 # No need to remove these directories and files, as they will get nuked in
122 # the module-level teardown.
123 # the module-level teardown.
123 prof_file = tempfile.NamedTemporaryFile(prefix='profile_', dir=IP_TEST_DIR)
124 td = tempfile.mkdtemp(dir=TMP_TEST_DIR)
124 prof_dir = tempfile.mkdtemp(prefix='profile_', dir=IP_TEST_DIR)
125 td = py3compat.str_to_unicode(td)
125 # Now, check that the profile listing doesn't get confused by files named
126 for name in ('profile_foo', u'profile_ünicode', 'profile_hello',
126 # profile_X
127 'not_a_profile'):
127 prof_name = os.path.split(prof_dir)[1].split('profile_')[1]
128 os.mkdir(os.path.join(td, name))
128 profiles = list_profiles_in(IP_TEST_DIR)
129 with open(os.path.join(td, 'profile_file'), 'w') as f:
129 nt.assert_equals(profiles, [prof_name])
130 f.write("I am not a profile directory")
131 profiles = list_profiles_in(td)
130
132
133 # unicode normalization can turn u'ünicode' into u'u\0308nicode',
134 # so only check for *nicode, and that creating a ProfileDir from the
135 # name remains valid
136 found_unicode = False
137 for p in list(profiles):
138 if p.endswith('nicode'):
139 pd = ProfileDir.find_profile_dir_by_name(td, p)
140 profiles.remove(p)
141 found_unicode = True
142 break
143 nt.assert_true(found_unicode)
144 nt.assert_equals(set(profiles), set(['foo', 'hello']))
145
131
146
132 def test_list_bundled_profiles():
147 def test_list_bundled_profiles():
133 # This variable will need to be updated when a new profile gets bundled
148 # This variable will need to be updated when a new profile gets bundled
134 bundled_true = [u'cluster', u'math', u'pysh', u'python3', u'sympy']
149 bundled_true = [u'cluster', u'math', u'pysh', u'python3', u'sympy']
135 bundled = sorted(list_bundled_profiles())
150 bundled = sorted(list_bundled_profiles())
136 nt.assert_equals(bundled, bundled_true)
151 nt.assert_equals(bundled, bundled_true)
137
General Comments 0
You need to be logged in to leave comments. Login now