annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
32
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
3 import os
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
4 from profilemanager import ProfileManager
12
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
32
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
6 # Get the path to the test profiles.ini file:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
7 from pkg_resources import resource_filename
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
8 profiles_dir = os.path.join('tests', 'profiles')
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
9 path = os.path.join(profiles_dir, 'profiles.ini')
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
10 profiles = resource_filename('profilemanager', path)
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
11 profiles_dir = resource_filename('profilemanager', profiles_dir)
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
12 assert os.path.exists(profiles)
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
13 assert os.path.exists(profiles_dir)
12
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
32
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
15 # Instatiate a ProfileManager:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
16 manager = ProfileManager(profiles)
12
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
32
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
18 # Remove any profiles that didn't get cleaned up:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
19 profiles_dict = manager.profiles_dict()
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
20 for profile in profiles_dict:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
21 manager.remove(profile)
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
22 assert os.listdir(profiles_dir) == ['profiles.ini']
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
23 assert file(profiles).read().strip() == '[General]'
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
24
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
25 # Create a new profile:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
26 profiledir = manager.new('testprofile')
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
27 assert profiledir.endswith('.testprofile')
12
a07e53273b70 adding stubs for tests
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28
32
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
29 # Cleanup:
6f2ad307fdda dont use any testing framework because they make testing hard
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
30 manager.remove('testprofile')