From: Oleg Broytman Date: Sun, 10 Apr 2016 10:45:25 +0000 (+0300) Subject: Refactoring: move import_inpx to TestCase X-Git-Tag: 0.0.4~20 X-Git-Url: https://git.phdru.name/?p=m_librarian.git;a=commitdiff_plain;h=41a3cb1231cb3659177166562fe3e574fd3c5eba Refactoring: move import_inpx to TestCase --- diff --git a/tests/__init__.py b/tests/__init__.py index c624381..da9e6a5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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: diff --git a/tests/test_inp.py b/tests/test_inp.py index ff3cfa4..595c46d 100755 --- a/tests/test_inp.py +++ b/tests/test_inp.py @@ -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)