Mercurial > mozilla > hg > ProfileManager
comparison profilemanager/tests/test.py @ 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 | d4f0c1c4d0eb |
children | 5a27ad649768 |
comparison
equal
deleted
inserted
replaced
31:216a74146d16 | 32:6f2ad307fdda |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 """ | 3 import os |
4 doctest runner | 4 from profilemanager import ProfileManager |
5 """ | |
6 | 5 |
7 import doctest | 6 # Get the path to the test profiles.ini file: |
8 import os | 7 from pkg_resources import resource_filename |
8 profiles_dir = os.path.join('tests', 'profiles') | |
9 path = os.path.join(profiles_dir, 'profiles.ini') | |
10 profiles = resource_filename('profilemanager', path) | |
11 profiles_dir = resource_filename('profilemanager', profiles_dir) | |
12 assert os.path.exists(profiles) | |
13 assert os.path.exists(profiles_dir) | |
9 | 14 |
10 def run_tests(): | 15 # Instatiate a ProfileManager: |
11 directory = os.path.dirname(os.path.abspath(__file__)) | 16 manager = ProfileManager(profiles) |
12 tests = [ test for test in os.listdir(directory) | |
13 if test.endswith('.txt') ] | |
14 | 17 |
15 for test in tests: | 18 # Remove any profiles that didn't get cleaned up: |
16 doctest.testfile(test) | 19 profiles_dict = manager.profiles_dict() |
20 for profile in profiles_dict: | |
21 manager.remove(profile) | |
22 assert os.listdir(profiles_dir) == ['profiles.ini'] | |
23 assert file(profiles).read().strip() == '[General]' | |
24 | |
25 # Create a new profile: | |
26 profiledir = manager.new('testprofile') | |
27 assert profiledir.endswith('.testprofile') | |
17 | 28 |
18 if __name__ == '__main__': | 29 # Cleanup: |
19 run_tests() | 30 manager.remove('testprofile') |
20 |