Skip to content

Commit

Permalink
Updates for Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ogenstad committed Jun 1, 2016
1 parent ad2059a commit 62c5eb3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/parsing/yaml/test_parsing_yaml.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
"""Tests to validate yaml features."""
from nelkit.exceptions import FileNotFound, ParsingError
from nelkit.parsing.yaml.loader import YamlLoader
import os
import pytest
s = os.sep


def test_YamlLoader():
"""Test to see that the YamlLoader returns a dict."""
yl = YamlLoader(filename='tests/parsing/yaml/data/base.yml')
yl = YamlLoader(filename='tests%sparsing%syaml%sdata%sbase.yml' % (s, s, s, s))
assert isinstance(yl.data, dict)


def test_load_missing_file():
"""Test to verify that an exception is raised when trying to load a non-existing file."""
with pytest.raises(FileNotFound) as excinfo:
YamlLoader(filename='tests/parsing/yaml/data/file_that_does_not_exist.yml')
assert 'Unable to read: tests/parsing/yaml/data/file_that_does_not_exist.yml' == str(excinfo.value)
YamlLoader(filename='tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % (s, s, s, s))
assert 'Unable to read: tests%sparsing%syaml%sdata%sfile_that_does_not_exist.yml' % (
s, s, s, s) == str(excinfo.value)


def test_load_invalid_file():
"""Test to verify that an exception is raised when the yaml file is invalid."""
with pytest.raises(ParsingError) as excinfo:
YamlLoader(filename='tests/parsing/yaml/data/invalid_yaml.yml')
assert 'tests/parsing/yaml/data/invalid_yaml.yml is not a valid yaml file' == str(excinfo.value)
YamlLoader(filename='tests%sparsing%syaml%sdata%sinvalid_yaml.yml' % (s, s, s, s))
assert 'tests%sparsing%syaml%sdata%sinvalid_yaml.yml is not a valid yaml file' % (
s, s, s, s) == str(excinfo.value)

0 comments on commit 62c5eb3

Please sign in to comment.