Mercurial > mozilla > hg > ProfileManager
view profilemanager/tests/test_profilemanager.txt @ 30:d9886a7e8df7
return the full directory path
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 06 May 2010 16:53:33 -0700 |
parents | d4f0c1c4d0eb |
children |
line wrap: on
line source
Test ProfileManager =================== The obligatory imports: >>> import os >>> from profilemanager import ProfileManager Get the path to the test profiles.ini file: >>> from pkg_resources import resource_filename >>> profiles_dir = os.path.join('tests', 'profiles') >>> path = os.path.join(profiles_dir, 'profiles.ini') >>> profiles = resource_filename('profilemanager', path) >>> profiles_dir = resource_filename('profilemanager', profiles_dir) >>> os.path.exists(profiles) True >>> os.path.exists(profiles_dir) True Instatiate a ProfileManager: >>> manager = ProfileManager(profiles) Remove any profiles that didn't get cleaned up: >>> profiles_dict = manager.profiles_dict() >>> for profile in profiles_dict: ... manager.remove(profile) >>> os.listdir(profiles_dir) ['profiles.ini'] >>> file(profiles).read().strip() '[General]' Create a new profile: >>> profiledir = manager.new('testprofile') >>> profiledir '...profilemanager/tests/profiles/...testprofile' Cleanup: >>> manager.remove('testprofile')