TestObjectReprFormatters.test_format_repr_info()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
1
import unittest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from foil.formatters import format_repr, format_repr_info
4
5
6
class Klass:
7
    def __init__(self, z, y):
8
        self.z = z
0 ignored issues
show
Coding Style Naming introduced by
The name z does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
9
        self.y = y
0 ignored issues
show
Coding Style Naming introduced by
The name y does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
10
11
12
class TestObjectReprFormatters(unittest.TestCase):
13
    def setUp(self):
14
        self.obj = Klass('hello', 10)
15
        self.attributes = ['z', 'y']
16
17
    def test_format_repr(self):
18
        result = format_repr(self.obj, self.attributes)
19
        expected = "Klass(z='hello', y=10)"
20
21
        self.assertEqual(expected, result)
22
23
    def test_format_repr_info(self):
24
        result = format_repr_info(self.obj, self.attributes)
25
        expected = "<Klass(z='hello', y=10)>"
26
27
        self.assertEqual(expected, result)
28