Merge pull request #47 from poikjhn/tests
More tests, coverage reporting
This commit is contained in:
commit
eb4b154cb9
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.py[co]
|
*.py[co]
|
||||||
*.sw[po]
|
*.sw[po]
|
||||||
.cache/
|
.cache/
|
||||||
|
.coverage
|
||||||
|
@ -3,6 +3,8 @@ python:
|
|||||||
- "3.3"
|
- "3.3"
|
||||||
- "3.4"
|
- "3.4"
|
||||||
- "3.5"
|
- "3.5"
|
||||||
|
before_install:
|
||||||
|
- pip install pytest pytest-cov
|
||||||
install: "pip install -r requirements.txt"
|
install: "pip install -r requirements.txt"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
@ -90,4 +90,4 @@ fi
|
|||||||
# Test buku(1) with $repo_root at the beginning of $PATH (so that buku
|
# Test buku(1) with $repo_root at the beginning of $PATH (so that buku
|
||||||
# from this repo is picked up).
|
# from this repo is picked up).
|
||||||
cd $here
|
cd $here
|
||||||
PATH="$repo_root:$PATH" python -m pytest test_*.py
|
PATH="$repo_root:$PATH" python -m pytest test_*.py --cov buku
|
||||||
|
@ -205,8 +205,19 @@ class TestBukuDb(unittest.TestCase):
|
|||||||
# def test_browse_by_index(self):
|
# def test_browse_by_index(self):
|
||||||
# self.fail()
|
# self.fail()
|
||||||
|
|
||||||
# def test_close_quit(self):
|
# @unittest.skip('skipping')
|
||||||
# self.fail()
|
def test_close_quit(self):
|
||||||
|
bdb=BukuDb()
|
||||||
|
# quitting with no args
|
||||||
|
try:
|
||||||
|
bdb.close_quit()
|
||||||
|
except SystemExit as err:
|
||||||
|
self.assertEqual(err.args[0], 0)
|
||||||
|
# quitting with custom arg
|
||||||
|
try:
|
||||||
|
bdb.close_quit(1)
|
||||||
|
except SystemExit as err:
|
||||||
|
self.assertEqual(err.args[0], 1)
|
||||||
|
|
||||||
# def test_import_bookmark(self):
|
# def test_import_bookmark(self):
|
||||||
# self.fail()
|
# self.fail()
|
||||||
|
38
tests/test_helpers.py
Normal file
38
tests/test_helpers.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import imp, unittest
|
||||||
|
|
||||||
|
buku = imp.load_source('buku', '../buku')
|
||||||
|
|
||||||
|
from buku import parse_tags
|
||||||
|
|
||||||
|
|
||||||
|
class TestHelpers(unittest.TestCase):
|
||||||
|
|
||||||
|
# @unittest.skip('skipping')
|
||||||
|
def test_parse_tags(self):
|
||||||
|
# call without arguments
|
||||||
|
parsed = parse_tags()
|
||||||
|
self.assertIsNone(parsed)
|
||||||
|
# empty tags
|
||||||
|
parsed = parse_tags([",,,,,"])
|
||||||
|
self.assertEqual(parsed, ",")
|
||||||
|
# sorting tags
|
||||||
|
parsed = parse_tags(["z_tag,a_tag,n_tag"])
|
||||||
|
self.assertEqual(parsed, ",a_tag,n_tag,z_tag,")
|
||||||
|
# whitespaces
|
||||||
|
parsed = parse_tags([" a tag , , , ,\t,\n,\r,\x0b,\x0c"])
|
||||||
|
self.assertEqual(parsed, ",a tag,")
|
||||||
|
# duplicates, excessive spaces
|
||||||
|
parsed = parse_tags(["tag,tag, tag, tag,tag , tag "])
|
||||||
|
self.assertEqual(parsed, ",tag,")
|
||||||
|
# escaping quotes
|
||||||
|
parsed = parse_tags(["\"tag\",\'tag\',tag"])
|
||||||
|
self.assertEqual(parsed, ",\"tag\",\'tag\',tag,")
|
||||||
|
# combo
|
||||||
|
parsed = parse_tags([",,z_tag, a tag ,\t,,, ,n_tag ,n_tag, a_tag, \na tag ,\r, \"a_tag\""])
|
||||||
|
self.assertEqual(parsed, ",\"a_tag\",a tag,a_tag,n_tag,z_tag,")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user