+Version 0.0.15 (2016-07-??)
+
+ Use pytest for testing.
+
Version 0.0.14 (2016-07-29)
Python 3: support for Py2 and Py3 (3.4+) with one codebase.
--- /dev/null
+-r requirements.txt
+
+pytest
.PHONY: all
all:
- ./run_all.py
+ pytest
def import_inpx(self, inpx):
import_inpx(os.path.join(os.path.dirname(__file__), inpx))
-
-
-def main():
- try:
- unittest.main(testRunner=unittest.TextTestRunner())
- except SystemExit as msg:
- result = msg.args[0]
- else:
- result = 0
- raise SystemExit(result)
+++ /dev/null
-#! /usr/bin/env python
-
-
-from __future__ import print_function
-import os
-import sys
-import subprocess
-
-
-def isexecutable(filename):
- infile = open(filename, 'r')
- magic = infile.read(2)
- infile.close()
- return magic == "#!"
-
-
-def collect_tests():
- tests = []
- for dirpath, dirs, files in os.walk("tests"):
- tests.extend(
- [os.path.join(dirpath, filename) for filename in files
- if filename.startswith("test") and filename.endswith(".py")
- ])
- return [test[:-3].replace(os.sep, '.') for test in tests
- if isexecutable(test)]
-
-
-def main():
- os.chdir(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
- tests = collect_tests()
-
- os.environ["PYTHONPATH"] = os.curdir
-
- for test in sorted(tests):
- print(test)
- subprocess.call((sys.executable, '-m', test))
-
-if __name__ == '__main__':
- main()
[library]
path = /home/test-config
+
+[download]
+format = %f
-#! /usr/bin/env python
import os
import unittest
-from tests import main
from m_librarian.config import get_config
get_config(config_path)
ml_conf = get_config()
self.assertEqual(ml_conf.get('library', 'path'), '/home/test-config')
-
-
-if __name__ == "__main__":
- main()
-#! /usr/bin/env python
-
+import os
import unittest
-from tests import main
-from m_librarian import config, download
+from m_librarian import download
+from m_librarian.config import get_config
class TestFormat(unittest.TestCase):
def test_compile_format(self):
- config.get_config().set('download', 'format', '%a/%s/%n %t')
+ config_path = os.path.join(
+ os.path.dirname(__file__), 'test_config.conf')
+ get_config(config_path)
+ ml_conf = get_config()
+ ml_conf.set('download', 'format', '%a/%s/%n %t')
download._compile_format()
self.assertEqual(download.compiled_format,
u'%(author)s/%(series)s/%(ser_no)d %(title)s')
-
-
-if __name__ == "__main__":
- main()
-#! /usr/bin/env python
-
-from tests import TestCase, main
+from tests import TestCase
from m_librarian.db import Genre
from m_librarian.glst import import_glst
def test_import_glst(self):
import_glst()
self.assertEqual(Genre.select().count(), 340)
-
-
-if __name__ == "__main__":
- main()
-#! /usr/bin/env python
-
-from tests import TestCase, main
+from tests import TestCase
from m_librarian.db import Author, Book
self.import_inpx('test.inpx')
self.assertEqual(Author.select().count(), 4)
self.assertEqual(Book.select().count(), 4)
-
-
-if __name__ == "__main__":
- main()
-#! /usr/bin/env python
# coding: utf-8
-
-from tests import TestCase, main
+from tests import TestCase
from m_librarian.db import Author, Book
from m_librarian.search import mk_search_conditions, \
search_authors, search_books
search_books('start', False,
{'title': u'ัะตัั'}, join_expressions).count(),
2)
-
-
-if __name__ == "__main__":
- main()