##// END OF EJS Templates
Add test for list_profiles_in
Fernando Perez -
Show More
@@ -82,7 +82,7 b' def win32_without_pywin32():'
82 return False
82 return False
83
83
84
84
85 class ProfileDirTest(TestCase):
85 class ProfileStartupTest(TestCase):
86 def setUp(self):
86 def setUp(self):
87 # create profile dir
87 # create profile dir
88 self.pd = ProfileDir.create_profile_dir_by_name(IP_TEST_DIR, 'test')
88 self.pd = ProfileDir.create_profile_dir_by_name(IP_TEST_DIR, 'test')
@@ -90,6 +90,8 b' class ProfileDirTest(TestCase):'
90 self.fname = os.path.join(TMP_TEST_DIR, 'test.py')
90 self.fname = os.path.join(TMP_TEST_DIR, 'test.py')
91
91
92 def tearDown(self):
92 def tearDown(self):
93 # We must remove this profile right away so its presence doesn't
94 # confuse other tests.
93 shutil.rmtree(self.pd.location)
95 shutil.rmtree(self.pd.location)
94
96
95 def init(self, startup_file, startup, test):
97 def init(self, startup_file, startup, test):
@@ -101,7 +103,6 b' class ProfileDirTest(TestCase):'
101 f.write(py3compat.doctest_refactor_print(test))
103 f.write(py3compat.doctest_refactor_print(test))
102
104
103 def validate(self, output):
105 def validate(self, output):
104 # validate output
105 tt.ipexec_validate(self.fname, output, '', options=self.options)
106 tt.ipexec_validate(self.fname, output, '', options=self.options)
106
107
107 @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows")
108 @dec.skipif(win32_without_pywin32(), "Test requires pywin32 on Windows")
@@ -114,3 +115,19 b' class ProfileDirTest(TestCase):'
114 def test_startup_ipy(self):
115 def test_startup_ipy(self):
115 self.init('00-start.ipy', '%profile\n', '')
116 self.init('00-start.ipy', '%profile\n', '')
116 self.validate('test')
117 self.validate('test')
118
119
120 def test_list_profiles_in():
121 # No need to remove these directories and files, as they will get nuked in
122 # the module-level teardown.
123 prof_file = tempfile.NamedTemporaryFile(prefix='profile_', dir=IP_TEST_DIR)
124 prof_dir = tempfile.mkdtemp(prefix='profile_', dir=IP_TEST_DIR)
125 # Now, check that the profile listing doesn't get confused by files named
126 # profile_X
127 prof_name = os.path.split(prof_dir)[1].split('profile_')[1]
128 profiles = list_profiles_in(IP_TEST_DIR)
129 nt.assert_equals(profiles, [prof_name])
130
131
132 #def test_list_bundled_profiles():
133
General Comments 0
You need to be logged in to leave comments. Login now