File: test_api.py

package info (click to toggle)
python-eliot 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: python: 8,641; makefile: 151
file content (86 lines) | stat: -rw-r--r-- 2,536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Tests for the public API exposed by L{eliot}.
"""

from unittest import TestCase

from .._output import Logger
import eliot


class PublicAPITests(TestCase):
    """
    Tests for the public API.
    """

    def test_addDestination(self):
        """
        L{eliot.addDestination} adds destinations to the L{Destinations}
        attached to L{Logger}.
        """
        o = object()
        eliot.addDestination(o)
        self.addCleanup(eliot.removeDestination, o)
        self.assertIn(o, Logger._destinations._destinations)

    def test_removeDestination(self):
        """
        L{eliot.addDestination} removes destinations from the L{Destinations}
        attached to L{Logger}.
        """
        self.assertEqual(eliot.removeDestination, Logger._destinations.remove)

    def test_addGlobalFields(self):
        """
        L{eliot.addGlobalFields} calls the corresponding method on the
        L{Destinations} attached to L{Logger}.
        """
        self.assertEqual(eliot.addGlobalFields, Logger._destinations.addGlobalFields)


class PEP8Tests(TestCase):
    """
    Tests for the PEP 8 variant of the the public API.
    """

    def test_add_destination(self):
        """
        L{eliot.addDestionation} is the same as L{eliot.add_destination}.
        """
        self.assertIs(eliot.add_destination, eliot.addDestination)

    def test_remove_destination(self):
        """
        L{eliot.removeDestionation} is the same as L{eliot.remove_destination}.
        """
        self.assertIs(eliot.remove_destination, eliot.removeDestination)

    def test_add_global_fields(self):
        """
        L{eliot.add_global_fields} is the same as L{eliot.addGlobalFields}.
        """
        self.assertIs(eliot.add_global_fields, eliot.addGlobalFields)

    def test_write_traceback(self):
        """
        L{eliot.writeTraceback} is the same as L{eliot.write_traceback}.
        """
        self.assertIs(eliot.write_traceback, eliot.writeTraceback)

    def test_write_failure(self):
        """
        L{eliot.writeFailure} is the same as L{eliot.write_failure}.
        """
        self.assertIs(eliot.write_failure, eliot.writeFailure)

    def test_start_task(self):
        """
        L{eliot.startTask} is the same as L{eliot.start_task}.
        """
        self.assertIs(eliot.start_task, eliot.startTask)

    def test_start_action(self):
        """
        L{eliot.startAction} is the same as L{eliot.start_action}.
        """
        self.assertIs(eliot.start_action, eliot.startAction)