Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for existence_check in tools.py #469

Merged
merged 1 commit into from
Apr 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/test_existence_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Test the existence_check function from the tools.py module."""
from __future__ import absolute_import

from .check import Check

from proselint.tools import existence_check as chk


class TestCheck(Check):
"""The test class for tools.existence_check."""

__test__ = True

@property
def this_check(self):
"""Bolierplate."""
return chk

def setUp(self):
"""setUp method creating some test fixtures."""
self.l = ['abc']
self.err = 'error message'
self.msg = 'it exists'

def test_smoke(self):
"""Basic smoke test to determine that existence_check is working."""
assert chk(
"""abc is as easy as 123""", self.l, self.err, self.msg) != []
assert chk(
"""easy breezy""", self.l, self.err, self.msg) == []
assert self.err in chk(
"""abc is as easy as 123""", self.l, self.err, self.msg)[0]
assert self.msg in chk(
"""abc is as easy as 123""", self.l, self.err, self.msg)[0]

def test_multiple_matches(self):
"""Test that multiple matches are found correctly."""
assert len(
chk("""abc and abc are as easy as 123""",
self.l, self.err, self.msg)) == 2
assert len(
chk("""ABC and abc are as easy as 123""",
self.l, self.err, self.msg, ignore_case=True)) == 2
assert chk(
"""abcabc are easy as 123""", self.l, self.err, self.msg) == []

def test_string_types(self):
"""Test that the function works with different string types."""
assert chk('abc is easy as 123', self.l, self.err, self.msg) != []
assert chk("abc is easy as 123", self.l, self.err, self.msg) != []
assert chk(u'abc is easy as 123', self.l, self.err, self.msg) != []
assert chk(u"abc is easy as 123", self.l, self.err, self.msg) != []