Mercurial > mozilla > hg > ProfileManager
changeset 32:6f2ad307fdda
dont use any testing framework because they make testing hard
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 06 May 2010 17:35:43 -0700 |
parents | 216a74146d16 |
children | 7b2da536bc6c |
files | profilemanager/tests/test.py profilemanager/tests/test_profilemanager.txt |
diffstat | 2 files changed, 24 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/profilemanager/tests/test.py Thu May 06 16:56:48 2010 -0700 +++ b/profilemanager/tests/test.py Thu May 06 17:35:43 2010 -0700 @@ -1,20 +1,30 @@ #!/usr/bin/env python -""" -doctest runner -""" +import os +from profilemanager import ProfileManager -import doctest -import os +# 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) +assert os.path.exists(profiles) +assert os.path.exists(profiles_dir) -def run_tests(): - directory = os.path.dirname(os.path.abspath(__file__)) - tests = [ test for test in os.listdir(directory) - if test.endswith('.txt') ] +# Instatiate a ProfileManager: +manager = ProfileManager(profiles) - for test in tests: - doctest.testfile(test) +# Remove any profiles that didn't get cleaned up: +profiles_dict = manager.profiles_dict() +for profile in profiles_dict: + manager.remove(profile) +assert os.listdir(profiles_dir) == ['profiles.ini'] +assert file(profiles).read().strip() == '[General]' + +# Create a new profile: +profiledir = manager.new('testprofile') +assert profiledir.endswith('.testprofile') -if __name__ == '__main__': - run_tests() - +# Cleanup: +manager.remove('testprofile')
--- a/profilemanager/tests/test_profilemanager.txt Thu May 06 16:56:48 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -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')