From 41a3cb1231cb3659177166562fe3e574fd3c5eba Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 10 Apr 2016 13:45:25 +0300 Subject: [PATCH] Refactoring: move import_inpx to TestCase --- tests/__init__.py | 4 ++++ tests/test_inp.py | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) 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) -- 2.39.2