|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 | import unittest
|
17 | 17 |
|
| 18 | +import pytest |
| 19 | + |
18 | 20 | from pydifact.control import Characters
|
19 | 21 |
|
20 | 22 |
|
21 |
| -class TestControlCharacters(unittest.TestCase): |
22 |
| - def setUp(self): |
23 |
| - self.cc = Characters() |
| 23 | +@pytest.fixture |
| 24 | +def cc(): |
| 25 | + return Characters() |
| 26 | + |
| 27 | + |
| 28 | +def test_wrong_attribute(cc): |
| 29 | + with pytest.raises(AttributeError): |
| 30 | + cc.with_control_character("wrongtype", "+") |
24 | 31 |
|
25 |
| - def test_wrong_attribute(self): |
26 |
| - self.assertRaises( |
27 |
| - AttributeError, self.cc.with_control_character, "wrongtype", "+" |
28 |
| - ) |
29 | 32 |
|
30 |
| - def test_wrong_character_size(self): |
31 |
| - self.assertRaises( |
32 |
| - ValueError, self.cc.with_control_character, "decimal_point", ",." |
33 |
| - ) |
| 33 | +def test_wrong_character_size(cc): |
| 34 | + with pytest.raises(ValueError): |
| 35 | + cc.with_control_character("decimal_point", ",.") |
34 | 36 |
|
35 |
| - def test_correct_parameters(self): |
36 |
| - d = self.cc.with_control_character("component_separator", "/") |
37 | 37 |
|
38 |
| - self.assertEqual( |
39 |
| - self.cc.with_control_character( |
40 |
| - "component_separator", "/" |
41 |
| - ).component_separator, |
42 |
| - "/", |
43 |
| - ) |
| 38 | +def test_correct_parameters(cc): |
| 39 | + assert ( |
| 40 | + cc.with_control_character("component_separator", "/").component_separator == "/" |
| 41 | + ) |
44 | 42 |
|
45 |
| - self.assertEqual( |
46 |
| - self.cc.with_control_character("data_separator", "/").data_separator, "/" |
47 |
| - ) |
| 43 | + assert cc.with_control_character("data_separator", "/").data_separator == "/" |
48 | 44 |
|
49 |
| - self.assertEqual( |
50 |
| - self.cc.with_control_character("decimal_point", "/").decimal_point, "/" |
51 |
| - ) |
| 45 | + assert cc.with_control_character("decimal_point", "/").decimal_point == "/" |
52 | 46 |
|
53 |
| - self.assertEqual( |
54 |
| - self.cc.with_control_character("escape_character", "/").escape_character, |
55 |
| - "/", |
56 |
| - ) |
| 47 | + assert cc.with_control_character("escape_character", "/").escape_character == "/" |
57 | 48 |
|
58 |
| - self.assertEqual( |
59 |
| - self.cc.with_control_character( |
60 |
| - "reserved_character", "/" |
61 |
| - ).reserved_character, |
62 |
| - "/", |
63 |
| - ) |
| 49 | + assert ( |
| 50 | + cc.with_control_character("reserved_character", "/").reserved_character == "/" |
| 51 | + ) |
64 | 52 |
|
65 |
| - self.assertEqual( |
66 |
| - self.cc.with_control_character( |
67 |
| - "segment_terminator", "/" |
68 |
| - ).segment_terminator, |
69 |
| - "/", |
70 |
| - ) |
| 53 | + assert ( |
| 54 | + cc.with_control_character("segment_terminator", "/").segment_terminator == "/" |
| 55 | + ) |
0 commit comments