|
1 | 1 | """Tests to validate yaml features.""" |
2 | 2 | from nelkit.exceptions import FileNotFound, ParsingError |
3 | 3 | from nelkit.parsing.yaml.loader import YamlLoader |
| 4 | +import os |
4 | 5 | import pytest |
| 6 | +s = os.sep |
5 | 7 |
|
6 | 8 |
|
7 | 9 | def test_YamlLoader(): |
8 | 10 | """Test to see that the YamlLoader returns a dict.""" |
9 | | - yl = YamlLoader(filename='tests/parsing/yaml/data/base.yml') |
| 11 | + yl = YamlLoader(filename='tests%sparsing%syaml%sdata%sbase.yml' % (s, s, s, s)) |
10 | 12 | assert isinstance(yl.data, dict) |
11 | 13 |
|
12 | 14 |
|
13 | 15 | def test_load_missing_file(): |
14 | 16 | """Test to verify that an exception is raised when trying to load a non-existing file.""" |
15 | 17 | with pytest.raises(FileNotFound) as excinfo: |
16 | | - YamlLoader(filename='tests/parsing/yaml/data/file_that_does_not_exist.yml') |
17 | | - assert 'Unable to read: tests/parsing/yaml/data/file_that_does_not_exist.yml' == str(excinfo.value) |
| 18 | + YamlLoader(filename='tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % (s, s, s, s)) |
| 19 | + assert 'Unable to read: tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % ( |
| 20 | + s, s, s, s) == str(excinfo.value) |
18 | 21 |
|
19 | 22 |
|
20 | 23 | def test_load_invalid_file(): |
21 | 24 | """Test to verify that an exception is raised when the yaml file is invalid.""" |
22 | 25 | with pytest.raises(ParsingError) as excinfo: |
23 | | - YamlLoader(filename='tests/parsing/yaml/data/invalid_yaml.yml') |
24 | | - assert 'tests/parsing/yaml/data/invalid_yaml.yml is not a valid yaml file' == str(excinfo.value) |
| 26 | + YamlLoader(filename='tests%sparsing%syaml%sdata%sinvalid_yaml.yml' % (s, s, s, s)) |
| 27 | + assert 'tests%sparsing%syaml%sdata%sinvalid_yaml.yml is not a valid yaml file' % ( |
| 28 | + s, s, s, s) == str(excinfo.value) |
0 commit comments