]> git.phdru.name Git - m_librarian.git/commitdiff
Use pytest for testing
authorOleg Broytman <phd@phdru.name>
Sun, 11 Sep 2016 19:15:35 +0000 (22:15 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 11 Sep 2016 19:15:35 +0000 (22:15 +0300)
ChangeLog
requirements_dev.txt [new file with mode: 0644]
tests/Makefile
tests/__init__.py
tests/run_all.py [deleted file]
tests/test_config.conf
tests/test_config.py [changed mode: 0755->0644]
tests/test_format.py [changed mode: 0755->0644]
tests/test_glst.py [changed mode: 0755->0644]
tests/test_inp.py [changed mode: 0755->0644]
tests/test_search.py [changed mode: 0755->0644]

index e0d2c0e757eaae2ba752352f6d6d83b638556671..7367ef1e034fff7539ee61b0a0d91fa13b7787d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/requirements_dev.txt b/requirements_dev.txt
new file mode 100644 (file)
index 0000000..73c8ac6
--- /dev/null
@@ -0,0 +1,3 @@
+-r requirements.txt
+
+pytest
index b990065cfd8bab40e800e4f3987644c570fca99e..0c6125e273addd4339eff70c6d6648d8395c5a25 100644 (file)
@@ -1,4 +1,4 @@
 
 .PHONY: all
 all:
-       ./run_all.py
+       pytest
index e55661f9673427fac81535862bee5987575a2d24..598d46398df8401edf82963571e000c61eebd545 100644 (file)
@@ -24,13 +24,3 @@ class TestCase(unittest.TestCase):
 
     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)
diff --git a/tests/run_all.py b/tests/run_all.py
deleted file mode 100755 (executable)
index c04d9ed..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /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()
index 8154b2bbd1ceeb345403d6bd57714b73e9d1e293..249deef8659132de3772fbb6656a73c7adf3664d 100644 (file)
@@ -1,2 +1,5 @@
 [library]
 path = /home/test-config
+
+[download]
+format = %f
old mode 100755 (executable)
new mode 100644 (file)
index 6e0c6a3..0a6e07b
@@ -1,8 +1,6 @@
-#! /usr/bin/env python
 
 import os
 import unittest
-from tests import main
 from m_librarian.config import get_config
 
 
@@ -13,7 +11,3 @@ class TestFormat(unittest.TestCase):
         get_config(config_path)
         ml_conf = get_config()
         self.assertEqual(ml_conf.get('library', 'path'), '/home/test-config')
-
-
-if __name__ == "__main__":
-    main()
old mode 100755 (executable)
new mode 100644 (file)
index 8dc1a22..2710af9
@@ -1,18 +1,17 @@
-#! /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()
old mode 100755 (executable)
new mode 100644 (file)
index 5349bb3..bf4bd0c
@@ -1,7 +1,5 @@
-#! /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
 
@@ -10,7 +8,3 @@ class TestGlst(TestCase):
     def test_import_glst(self):
         import_glst()
         self.assertEqual(Genre.select().count(), 340)
-
-
-if __name__ == "__main__":
-    main()
old mode 100755 (executable)
new mode 100644 (file)
index 6aeefd1..9471421
@@ -1,7 +1,5 @@
-#! /usr/bin/env python
 
-
-from tests import TestCase, main
+from tests import TestCase
 from m_librarian.db import Author, Book
 
 
@@ -13,7 +11,3 @@ class TestInp(TestCase):
         self.import_inpx('test.inpx')
         self.assertEqual(Author.select().count(), 4)
         self.assertEqual(Book.select().count(), 4)
-
-
-if __name__ == "__main__":
-    main()
old mode 100755 (executable)
new mode 100644 (file)
index bc6ceca..7fdf9fe
@@ -1,8 +1,6 @@
-#! /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
@@ -30,7 +28,3 @@ class TestSearch(TestCase):
             search_books('start', False,
                          {'title': u'ั‚ะตัั‚'}, join_expressions).count(),
             2)
-
-
-if __name__ == "__main__":
-    main()