]> git.phdru.name Git - m_librarian.git/commitdiff
Refactoring: move import_inpx to TestCase
authorOleg Broytman <phd@phdru.name>
Sun, 10 Apr 2016 10:45:25 +0000 (13:45 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 10 Apr 2016 10:45:25 +0000 (13:45 +0300)
tests/__init__.py
tests/test_inp.py

index c624381b6ad0e053f6cf370b1ea16d3b67df18dc..da9e6a5f19d5624729a1164a032aa2b3c21e955d 100644 (file)
@@ -5,6 +5,7 @@ __all__ = ['TestCase', 'main']
 import os
 import unittest
 from m_librarian.db import open_db, init_db
+from m_librarian.inp import import_inpx
 
 
 class TestCase(unittest.TestCase):
@@ -22,6 +23,9 @@ class TestCase(unittest.TestCase):
         except OSError:
             pass
 
+    def import_inpx(self, inpx):
+        import_inpx(os.path.join(os.path.dirname(__file__), inpx))
+
 
 def main():
     try:
index ff3cfa4f0884905acf3a59e1ccea66a0a5c9ae38..595c46d0191f1389e85568c16fc6c748771a25c7 100755 (executable)
@@ -4,17 +4,14 @@
 import os
 from tests import TestCase, main
 from m_librarian.db import Author, Book
-from m_librarian.inp import import_inpx
 
 
 class TestInp(TestCase):
     def test_import_bad_inpx(self):
-        self.assertRaises(
-            ValueError, import_inpx,
-            os.path.join(os.path.dirname(__file__), 'bad.inpx'))
+        self.assertRaises(ValueError, self.import_inpx, 'bad.inpx')
 
     def test_import_inpx(self):
-        import_inpx(os.path.join(os.path.dirname(__file__), 'test.inpx'))
+        self.import_inpx('test.inpx')
         self.assertEqual(Author.select().count(), 4)
         self.assertEqual(Book.select().count(), 4)