Example #1
0
    def test_01a(self):
        """
        Test Case 01a:
        Try opening an existing file using the :py:func:`magrathea.utils.file.open_file` function.

        Test is passed if a deprecation warning is raised.
        """
        fp, name = tempfile.mkstemp()
        os.write(fp, b"test string")
        os.close(fp)
        with self.assertWarns(DeprecationWarning):
            fd = open_file(name, 'r')
        fd.close()
        os.unlink(name)
Example #2
0
    def test_01b(self):
        """
        Test Case 01b:
        Try opening an existing file using the :py:func:`magrathea.utils.file.open_file` function.

        Test is passed if content can be read from file object and meets expectation.
        """
        fp, name = tempfile.mkstemp()
        os.write(fp, b"test string")
        os.close(fp)
        fd = open_file(name, 'r')
        result = fd.read()
        fd.close()
        os.unlink(name)
        self.assertEqual(result, "test string")