|
6 | 6 | def test_append_a_line(): |
7 | 7 | options = {"create": "yes", "line": "192.168.1.1 foo.bar foo"} |
8 | 8 |
|
9 | | - content = "127.0.0.1 localhost" |
| 9 | + content = b"127.0.0.1 localhost" |
10 | 10 |
|
11 | 11 | new_content = line_in_file(content, options) |
12 | | - expected = [content, options["line"]] |
| 12 | + expected = "\n".join([content.decode(), options["line"]]) |
13 | 13 |
|
14 | | - eq_(new_content, "\n".join(expected)) |
| 14 | + eq_(new_content, expected.encode()) |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def test_absent(): |
18 | 18 | absent_line = "192.168.1.1 foo.bar foo" |
19 | 19 | options = {"regexp": ".*foo$", "state": "absent"} |
20 | 20 |
|
21 | | - content = f"127.0.0.1 localhost\n{absent_line}" |
| 21 | + content = f"127.0.0.1 localhost\n{absent_line}".encode() |
22 | 22 |
|
23 | 23 | new_content = line_in_file(content, options) |
24 | 24 | expected = "127.0.0.1 localhost" |
25 | 25 |
|
26 | | - eq_(new_content, expected) |
| 26 | + eq_(new_content, expected.encode()) |
27 | 27 |
|
28 | 28 |
|
29 | 29 | def test_present(): |
30 | 30 | present_line = "192.168.1.1 foo.bar foo" |
31 | 31 | options = {"regexp": ".*foo$", "line": present_line} |
32 | 32 |
|
33 | | - content = f"127.0.0.1 localhost\n192.162.1.1 foo" |
| 33 | + content = b"127.0.0.1 localhost\n192.162.1.1 foo" |
34 | 34 |
|
35 | 35 | new_content = line_in_file(content, options) |
36 | 36 | expected = ["127.0.0.1 localhost", present_line] |
37 | 37 |
|
38 | | - eq_(new_content, "\n".join(expected)) |
| 38 | + eq_(new_content, "\n".join(expected).encode()) |
0 commit comments