Back to index

apport  2.3
Public Member Functions | Private Member Functions
test_apport_unpack.T Class Reference

List of all members.

Public Member Functions

def setUpClass
def tearDownClass
def tearDown
def test_unpack
def test_unpack_python
def test_help
def test_error

Private Member Functions

def _call
def _get_unpack

Detailed Description

Definition at line 16 of file test_apport_unpack.py.


Member Function Documentation

def test_apport_unpack.T._call (   self,
  argv 
) [private]

Definition at line 107 of file test_apport_unpack.py.

00107 
00108     def _call(self, argv):
00109         a = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00110         (out, err) = a.communicate()
00111         return (a.returncode, out.decode('UTF-8'), err.decode('UTF-8'))

Here is the caller graph for this function:

def test_apport_unpack.T._get_unpack (   self,
  fname 
) [private]

Definition at line 112 of file test_apport_unpack.py.

00112 
00113     def _get_unpack(self, fname):
00114         with open(os.path.join(self.unpack_dir, fname), 'rb') as f:
00115             return f.read()
00116 
00117 unittest.main()

Here is the caller graph for this function:

Definition at line 18 of file test_apport_unpack.py.

00018 
00019     def setUpClass(klass):
00020         klass.workdir = tempfile.mkdtemp()
00021 
00022         # create problem report file with all possible data types
00023         r = problem_report.ProblemReport()
00024         klass.utf8_str = b'a\xe2\x99\xa5b'
00025         klass.bindata = b'\x00\x01\xFF\x40'
00026         r['utf8'] = klass.utf8_str
00027         r['unicode'] = klass.utf8_str.decode('UTF-8')
00028         r['binary'] = klass.bindata
00029         r['compressed'] = problem_report.CompressedValue(b'FooFoo!')
00030 
00031         klass.report_file = os.path.join(klass.workdir, 'test.apport')
00032         with open(klass.report_file, 'wb') as f:
00033             r.write(f)
00034 
00035         klass.unpack_dir = os.path.join(klass.workdir, 'un pack')

Definition at line 40 of file test_apport_unpack.py.

00040 
00041     def tearDown(self):
00042         if os.path.isdir(self.unpack_dir):
00043             shutil.rmtree(self.unpack_dir)

Definition at line 37 of file test_apport_unpack.py.

00037 
00038     def tearDownClass(klass):
00039         shutil.rmtree(klass.workdir)

calling apport-unpack with wrong arguments

Definition at line 89 of file test_apport_unpack.py.

00089 
00090     def test_error(self):
00091         '''calling apport-unpack with wrong arguments'''
00092 
00093         (ret, out, err) = self._call(['apport-unpack'])
00094         self.assertEqual(ret, 1)
00095         self.assertEqual(err, '')
00096         self.assertTrue(out.startswith('Usage:'), out)
00097 
00098         (ret, out, err) = self._call(['apport-unpack', self.report_file])
00099         self.assertEqual(ret, 1)
00100         self.assertEqual(err, '')
00101         self.assertTrue(out.startswith('Usage:'), out)
00102 
00103         (ret, out, err) = self._call(['apport-unpack', '/nonexisting.crash', self.unpack_dir])
00104         self.assertEqual(ret, 1)
00105         self.assertTrue('/nonexisting.crash' in err)
00106         self.assertEqual(out, '')

Here is the call graph for this function:

calling apport-unpack with help

Definition at line 81 of file test_apport_unpack.py.

00081 
00082     def test_help(self):
00083         '''calling apport-unpack with help'''
00084 
00085         (ret, out, err) = self._call(['apport-unpack', '--help'])
00086         self.assertEqual(ret, 0)
00087         self.assertEqual(err, '')
00088         self.assertTrue(out.startswith('Usage:'), out)

Here is the call graph for this function:

apport-unpack for all possible data types

Definition at line 44 of file test_apport_unpack.py.

00044 
00045     def test_unpack(self):
00046         '''apport-unpack for all possible data types'''
00047 
00048         self.assertEqual(self._call(['apport-unpack', self.report_file, self.unpack_dir]),
00049                          (0, '', ''))
00050 
00051         self.assertEqual(self._get_unpack('utf8'), self.utf8_str)
00052         self.assertEqual(self._get_unpack('unicode'), self.utf8_str)
00053         self.assertEqual(self._get_unpack('binary'), self.bindata)
00054         self.assertEqual(self._get_unpack('compressed'), b'FooFoo!')

Here is the call graph for this function:

apport-unpack with explicity Python interpreter

This will catch Python 2/3 specific errors when running the tests with
a different $PYTHON than apport-unpacks' hashbang.

Definition at line 55 of file test_apport_unpack.py.

00055 
00056     def test_unpack_python(self):
00057         '''apport-unpack with explicity Python interpreter
00058 
00059         This will catch Python 2/3 specific errors when running the tests with
00060         a different $PYTHON than apport-unpacks' hashbang.
00061         '''
00062         apport_unpack = os.path.join(
00063             os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'bin',
00064             'apport-unpack')
00065         if not os.path.exists(apport_unpack):
00066             apport_unpack = '/usr/bin/apport-unpack'
00067         if not os.path.exists(apport_unpack):
00068             sys.stderr.write('[skip: apport-unpack not found] ')
00069             return
00070 
00071         self.assertEqual(self._call([os.getenv('PYTHON', 'python3'),
00072                                      apport_unpack,
00073                                      self.report_file,
00074                                      self.unpack_dir]),
00075                          (0, '', ''))
00076 
00077         self.assertEqual(self._get_unpack('utf8'), self.utf8_str)
00078         self.assertEqual(self._get_unpack('unicode'), self.utf8_str)
00079         self.assertEqual(self._get_unpack('binary'), self.bindata)
00080         self.assertEqual(self._get_unpack('compressed'), b'FooFoo!')

Here is the call graph for this function:


The documentation for this class was generated from the following file: