root/branches/mk/tests/functional/test_cleaning_up.py

Revision 60, 1.7 kB (checked in by mk, 7 years ago)

Check that Cheesecake is properly cleaning up (closes ticket #28).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 from glob import glob
2 import os
3 import tempfile
4 from StringIO import StringIO
5
6 from _path_cheesecake import CHEESECAKE_PATH
7 from _helper_cheesecake import read_file_contents
8
9 try:
10     import subprocess
11 except ImportError, ex:
12     from cheesecake import subprocess
13
14
15 class TestCleaningUp(object):
16     def setUp(self):
17         self.stdout_fd, self.stdout_name = tempfile.mkstemp(prefix='functional')
18         self.stderr_fd, self.stderr_name = tempfile.mkstemp(prefix='functional')
19         self.sandbox = tempfile.mkdtemp()
20         self.process = subprocess.Popen('%s -n ftputil -s %s' % \
21                                         (CHEESECAKE_PATH, self.sandbox),
22                          stdout=self.stdout_fd,
23                          stderr=self.stderr_fd,
24                          shell=True)
25         self.return_code = self.process.wait()
26
27     def tearDown(self):
28         os.unlink(self.stdout_name)
29         os.unlink(self.stderr_name)
30
31     def test_no_tmp(self):
32         "Check that no files are left in temp by Cheesecake."
33         print file(self.stdout_name).read()
34         print file(self.stderr_name).read()
35
36         # Check that Cheesecake exited sucessfully.
37         assert self.return_code == 0
38
39         # Check that Cheesecake didn't wrote anything into stderr.
40         assert read_file_contents(self.stderr_name) == ''
41
42         # Check that Cheesecake didn't left sandbox.
43         assert not os.path.exists(self.sandbox)
44
45         # Check that Cheesecake didn't left any cheesecake* files.
46         assert glob(os.path.join(tempfile.gettempdir(), "cheesecake*")) == []
47
48         # Check that Cheesecake didn't left any tmp* files
49         assert glob(os.path.join(tempfile.gettempdir(), tempfile.gettempprefix() + "*")) == []
Note: See TracBrowser for help on using the browser.