Exemplo n.º 1
0
    def test_override_duplicate_traceback(self):
        """Only the freshest traceback is stored."""
        path = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        exception_info = exc_utils.get_exception_info_1()

        storage = FileStorage(LOG_DIRECTORY)
        storage.save("duplicate:first", exception_info)
        self.assertTrue(file_exists(path))

        # duplicated exception
        exception_info = exc_utils.get_exception_info_1("arg", 25.3, self)
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("duplicate:second", exception_info)

        self.assertEqual("duplicate:second", self._get_file_contents(path))
Exemplo n.º 2
0
    def test_override_duplicate_traceback(self):
        """Only the freshest traceback is stored."""
        path = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        exception_info = exc_utils.get_exception_info_1()

        storage = FileStorage(LOG_DIRECTORY)
        storage.save("duplicate:first", exception_info)
        self.assertTrue(file_exists(path))

        # duplicated exception
        exception_info = exc_utils.get_exception_info_1("arg", 25.3, self)
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("duplicate:second", exception_info)

        self.assertEqual("duplicate:second", self._get_file_contents(path))
Exemplo n.º 3
0
    def test_exception_attributes(self):
        ATTRIBUTES = {
            "args": (
                "1",
                2,
                3.0,
            ),
            "pepek": "spinach",
        }

        if not py3k.PY3:
            # message attribute was removed in py3k
            # message is set to 1st argument only if it is the only argument
            ATTRIBUTES["message"] = ""

        info = get_exception_info_1("1", 2, 3.0)
        info.exception.pepek = "spinach"

        attribute_names = tuple(a.name for a in info.exception_attributes)
        for attr_name in ATTRIBUTES:
            self.assertTrue(attr_name in attribute_names)

        for a in info.exception_attributes:
            self.assertTrue(a.name in ATTRIBUTES)
            self.assertEqual(ATTRIBUTES[a.name], a.value)
Exemplo n.º 4
0
 def test_build_search_query_from_unicode(self):
     """
     In Python 2.6 this shouldn't raise exception below.
     TypeError: 'in ' requires string as left operand quote
     """
     info = get_exception_info_1()
     self.formatter._get_search_query(info)
Exemplo n.º 5
0
    def test_save(self):
        exception_info = exc_utils.get_exception_info_1()

        storage = FileStorage(LOG_DIRECTORY)
        storage.save("test_save", exception_info)

        path = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        self.assertTrue(file_exists(path))
Exemplo n.º 6
0
    def test_new_interface(self):
        message = "Something went wrong..."
        info = get_exception_info_1(message)

        self.assertEqual(info.type_name, "Exception")
        self.assertTrue(isinstance(info.type, type))
        self.assertTrue(isinstance(info.exception, Exception))
        self.assertEqual(info.message, message)
Exemplo n.º 7
0
    def test_new_interface(self):
        message = "Something went wrong..."
        info = get_exception_info_1(message)

        self.assertEqual(info.type_name, "Exception")
        self.assertTrue(isinstance(info.type, type))
        self.assertTrue(isinstance(info.exception, Exception))
        self.assertEqual(info.message, message)
Exemplo n.º 8
0
    def test_save(self):
        exception_info = exc_utils.get_exception_info_1()

        storage = FileStorage(LOG_DIRECTORY)
        storage.save("test_save", exception_info)

        path = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        self.assertTrue(file_exists(path))
Exemplo n.º 9
0
    def test_compatibility_with_exc_info_result(self):
        info = get_exception_info_1()

        self.assertTrue(isinstance(info, tuple))
        self.assertEqual(len(info), 3)

        exception_type, exception, traceback = info
        self.assertTrue(isinstance(exception_type, type))
        self.assertTrue(isinstance(exception, Exception))
Exemplo n.º 10
0
    def test_compatibility_with_exc_info_result(self):
        info = get_exception_info_1()

        self.assertTrue(isinstance(info, tuple))
        self.assertEqual(len(info), 3)

        exception_type, exception, traceback = info
        self.assertTrue(isinstance(exception_type, type))
        self.assertTrue(isinstance(exception, Exception))
Exemplo n.º 11
0
    def test_save_different_tracebacks(self):
        path_1 = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        path_2 = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_2)

        exception_info = exc_utils.get_exception_info_1()
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("diff:first", exception_info)
        self.assertTrue(file_exists(path_1))

        exception_info = exc_utils.get_exception_info_2()
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("diff:second", exception_info)
        self.assertTrue(file_exists(path_2))

        self.assertEqual("diff:first", self._get_file_contents(path_1))
        self.assertEqual("diff:second", self._get_file_contents(path_2))
Exemplo n.º 12
0
    def test_save_different_tracebacks(self):
        path_1 = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_1)
        path_2 = join(LOG_DIRECTORY, exc_utils.EXCEPTION_FILE_NAME_2)

        exception_info = exc_utils.get_exception_info_1()
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("diff:first", exception_info)
        self.assertTrue(file_exists(path_1))

        exception_info = exc_utils.get_exception_info_2()
        storage = FileStorage(LOG_DIRECTORY)
        storage.save("diff:second", exception_info)
        self.assertTrue(file_exists(path_2))

        self.assertEqual("diff:first", self._get_file_contents(path_1))
        self.assertEqual("diff:second", self._get_file_contents(path_2))
Exemplo n.º 13
0
    def test_exception_attributes(self):
        ATTRIBUTES = {
            "args": ("1", 2, 3.0,),
            "pepek": "spinach",
        }

        if not py3k.PY3:
            # message attribute was removed in py3k
            # message is set to 1st argument only if it is the only argument
            ATTRIBUTES["message"] = ""

        info = get_exception_info_1("1", 2, 3.0)
        info.exception.pepek = "spinach"

        attribute_names = tuple(a.name for a in info.exception_attributes)
        for attr_name in ATTRIBUTES:
            self.assertTrue(attr_name in attribute_names)

        for a in info.exception_attributes:
            self.assertTrue(a.name in ATTRIBUTES)
            self.assertEqual(ATTRIBUTES[a.name], a.value)
Exemplo n.º 14
0
 def test_text_properties_are_unicode(self):
     info = get_exception_info_1(3, 2, 1, "pepek")
     for frame in info.frames:
         self.assertTrue(isinstance(frame.path_to_file, unicode))
         self.assertTrue(isinstance(frame.routine_name, unicode))