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

Add unit tests #8

Merged
merged 6 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .coveragerc to control coverage.py

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma:
pragma: no cover

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
# Don't complain about debug code
if Image.DEBUG:
if DEBUG:
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
MANIFEST
build
dist
.coverage
htmlcov/
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: python

python:
- pypy
- pypy3
- 2.6
- 2.7
- 3.2
- 3.3
- 3.4
- 3.5

sudo: false

install:
- pip install coverage
- if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install unittest2; fi
# Coverage 4.0 doesn't support Python 3.2
- if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then travis_retry pip install coverage==3.7.1; fi
- if [ "$TRAVIS_PYTHON_VERSION" != "3.2" ]; then travis_retry pip install coverage; fi

script:
- coverage run --source=see ./test_see.py -v

after_success:
- pip install coveralls
- coveralls

after_script:
- coverage report
- pip install pep8 pyflakes
- pyflakes *.py | tee >(wc -l)
- pep8 --statistics --count *.py

matrix:
fast_finish: true
64 changes: 64 additions & 0 deletions test_see.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python
# encoding: utf-8
"""
Unit tests for see.py
"""
from __future__ import print_function, unicode_literals
try:
import unittest2 as unittest
except ImportError:
import unittest

import see


class TestSee(unittest.TestCase):

def test_line_width(self):
# Arrange
default_width = 1
max_width = 1

# Act
width = see.line_width(default_width, max_width)

# Assert
self.assertIsInstance(width, int)
self.assertEqual(width, 1)

def test_regex_filter(self):
# Arrange
names = ["george", "helen"]
pat = "or*"

# Act
out = see.regex_filter(names, pat)

# Assert
self.assertIsInstance(out, tuple)
self.assertEqual(out, ("george",))

def test_fn_filter(self):
# Arrange
names = ["george", "helen"]
pat = "*or*"

# Act
out = see.fn_filter(names, pat)

# Assert
self.assertIsInstance(out, tuple)
self.assertEqual(out, ("george",))

def test_see_with_no_args(self):
# Act
out = see.see()

# Assert
self.assertIsInstance(out, see._SeeOutput)


if __name__ == '__main__':
unittest.main()

# End of file