diff options
author | kballou <kballou@devnulllabs.io> | 2014-07-22 23:11:37 -0600 |
---|---|---|
committer | kballou <kballou@devnulllabs.io> | 2014-07-23 00:42:08 -0600 |
commit | e608e281450064faf46f1be80795968887e5a794 (patch) | |
tree | a976816af9d66b688906635180bc6f58e0ac5e87 /xnt | |
parent | 69647dbc389f4997d4f8884283b173d67f1a416a (diff) | |
download | xnt-e608e281450064faf46f1be80795968887e5a794.tar.gz xnt-e608e281450064faf46f1be80795968887e5a794.tar.xz |
Refactor test code
Move basic test assumptions (assumptions that are tested for all tasks)
into their own function in `xnt.tests`. Refactor all test methods to use
this new function.
Diffstat (limited to 'xnt')
-rw-r--r-- | xnt/tests/__init__.py | 10 | ||||
-rw-r--r-- | xnt/tests/compilercollectiontests.py | 79 | ||||
-rw-r--r-- | xnt/tests/maketests.py | 64 | ||||
-rw-r--r-- | xnt/tests/taskcompressiontests.py | 16 | ||||
-rw-r--r-- | xnt/tests/taskcopytests.py | 18 | ||||
-rw-r--r-- | xnt/tests/taskmisctests.py | 62 | ||||
-rw-r--r-- | xnt/tests/taskmkdirtests.py | 9 | ||||
-rw-r--r-- | xnt/tests/taskmovetests.py | 9 | ||||
-rw-r--r-- | xnt/tests/taskremovetests.py | 9 | ||||
-rw-r--r-- | xnt/tests/textests.py | 22 | ||||
-rw-r--r-- | xnt/tests/vcscvstests.py | 16 | ||||
-rw-r--r-- | xnt/tests/vcsgittests.py | 16 | ||||
-rw-r--r-- | xnt/tests/vcshgtests.py | 16 |
13 files changed, 67 insertions, 279 deletions
diff --git a/xnt/tests/__init__.py b/xnt/tests/__init__.py index 2da7dee..00bee50 100644 --- a/xnt/tests/__init__.py +++ b/xnt/tests/__init__.py @@ -16,3 +16,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. + +def assert_basic_assumptions(testcase, result): + '''Test function assert basic structure of task code''' + from types import FunctionType + testcase.assertIsNotNone(result) + testcase.assertIsInstance(result, tuple) + testcase.assertIsInstance(result[0], tuple) + testcase.assertEqual(len(result[0]), 2) + testcase.assertIsInstance(result[0][0], FunctionType) + testcase.assertIsInstance(result[0][1], dict) diff --git a/xnt/tests/compilercollectiontests.py b/xnt/tests/compilercollectiontests.py index 0a7139e..5c1effe 100644 --- a/xnt/tests/compilercollectiontests.py +++ b/xnt/tests/compilercollectiontests.py @@ -17,45 +17,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.build.cc import __gcc__ from xnt.build.cc import __gpp__ from xnt.build.cc import __nvcc__ from xnt.build.cc import __javac__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 class GccTests(unittest.TestCase): """Test GCC""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_gcc(self): """Test Default GCC""" result = __gcc__("hello.c") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue('flags' in result[0][1]) def test_gcc_with_output(self): """Test GCC with output""" result = __gcc__("hello.c", output="hello") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue("outfile" in result[0][1]) self.assertTrue('flags' in result[0][1]) @@ -63,35 +46,18 @@ class GccTests(unittest.TestCase): #pylint: disable-msg=C0103 class GppTests(unittest.TestCase): """Test G++ (C++ GCC)""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_gpp(self): """Test Default G++""" result = __gpp__("hello.cpp") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue('flags' in result[0][1]) def test_gpp_with_output(self): """Test G++ with output""" result = __gpp__("hello.cpp", output="hello") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue("outfile" in result[0][1]) self.assertTrue('flags' in result[0][1]) @@ -99,58 +65,29 @@ class GppTests(unittest.TestCase): #pylint: disable-msg=C0103 class NvccTests(unittest.TestCase): """Test NVCC""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_nvcc(self): """Test Default NVCC""" result = __nvcc__("hello.cu") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue('flags' in result[0][1]) def test_nvcc_with_output(self): """Test Named Output NVCC""" result = __nvcc__("hello.cu", output="hello") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("infile" in result[0][1]) self.assertTrue("outfile" in result[0][1]) self.assertTrue('flags' in result[0][1]) class JavacTests(unittest.TestCase): """Test Javac""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_javac(self): """Test Default Javac""" result = __javac__("HelloWorld.java") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("sourcefiles" in result[0][1]) self.assertTrue('flags' in result[0][1]) diff --git a/xnt/tests/maketests.py b/xnt/tests/maketests.py index a3d17d0..e0414b8 100644 --- a/xnt/tests/maketests.py +++ b/xnt/tests/maketests.py @@ -17,45 +17,33 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.build.make import __make__ from xnt.build.make import __ant__ from xnt.build.make import __nant__ -from types import FunctionType import unittest class AntTests(unittest.TestCase): """Test Case for Ant Build""" - def setUp(self): - """Test Setup""" - pass - - def tearDown(self): - """Test Teardown""" - pass def test_default_build(self): """Test the default target of ant""" result = __ant__(target="test") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('target' in result[0][1]) self.assertEqual('test', result[0][1]['target']) def test_ant_when_given_path(self): """Test ant when passing given a path""" result = __ant__(target="test", path="some/other/path/build.xml") - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('some/other/path/build.xml', result[0][1]['path']) def test_ant_when_given_flags(self): """Test passing flags to ant""" result = __ant__(target='test', flags=['-verbose']) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('flags' in result[0][1]) self.assertEqual(1, len(result[0][1]['flags'])) self.assertEqual('-verbose', result[0][1]['flags'][0]) @@ -65,7 +53,7 @@ class AntTests(unittest.TestCase): result = __ant__(target="test", pkeys=["test_var"], pvalues=["testing"]) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('pkeys' in result[0][1]) self.assertTrue('pvalues' in result[0][1]) self.assertEqual(1, len(result[0][1]['pkeys'])) @@ -76,30 +64,17 @@ class AntTests(unittest.TestCase): class MakeTests(unittest.TestCase): """GNU Make Tests""" - def setUp(self): - """Test Setup""" - pass - - def tearDown(self): - """Test Teardown""" - pass - def test_default_make(self): """Test Default make""" result = __make__(target="build") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(len(result[0]), 2) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('target' in result[0][1]) self.assertEqual('build', result[0][1]['target']) def test_make_with_path(self): '''Test make given a path''' result = __make__(target="build", path="some/other/path/Makefile") - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('some/other/path/Makefile', result[0][1]['path']) @@ -108,7 +83,7 @@ class MakeTests(unittest.TestCase): result = __make__(target='build', pkeys=["test_var"], pvalues=["testing"]) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('pkeys' in result[0][1]) self.assertTrue('pvalues' in result[0][1]) self.assertEqual(1, len(result[0][1]['pkeys'])) @@ -119,7 +94,7 @@ class MakeTests(unittest.TestCase): def test_passing_flags(self): """Test Flag Passing with Make""" result = __make__(target='build', flags=['-B']) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('flags' in result[0][1]) self.assertEqual(1, len(result[0][1]['flags'])) self.assertEqual('-B', result[0][1]['flags'][0]) @@ -127,30 +102,17 @@ class MakeTests(unittest.TestCase): class NAntTests(unittest.TestCase): """.NET Ant Tests""" - def setUp(self): - """Test Setup""" - pass - - def tearDown(self): - """Test Teardown""" - pass - def test_nant_with_target(self): """Test Deault nant""" result = __nant__(target='test') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('target' in result[0][1]) self.assertEqual('test', result[0][1]['target']) def test_nant_with_path(self): '''Test NAnt with path''' result = __nant__(target='test', path='some/other/path/build.xml') - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('some/other/path/build.xml', result[0][1]['path']) @@ -159,7 +121,7 @@ class NAntTests(unittest.TestCase): result = __nant__(target="test", pkeys=["test_var"], pvalues=["testing"]) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('pkeys' in result[0][1]) self.assertTrue('pvalues' in result[0][1]) self.assertEqual(1, len(result[0][1]['pkeys'])) @@ -169,7 +131,7 @@ class NAntTests(unittest.TestCase): def test_nant_with_flags(self): '''Test NAnt with flags''' result = __nant__(target="test", flags=["-v"]) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('flags' in result[0][1]) self.assertEqual(1, len(result[0][1]['flags'])) self.assertEqual('-v', result[0][1]['flags'][0]) diff --git a/xnt/tests/taskcompressiontests.py b/xnt/tests/taskcompressiontests.py index 0d36b49..06bdd6b 100644 --- a/xnt/tests/taskcompressiontests.py +++ b/xnt/tests/taskcompressiontests.py @@ -17,30 +17,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __zip__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 class TaskCompressionTests(unittest.TestCase): """Test Cases for Compression""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_zip(self): """Test zip method""" result = __zip__(directory="testfolder", zipfilename="myzip.zip") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue("directory" in result[0][1]) self.assertEqual("testfolder", result[0][1]['directory']) self.assertTrue("zipfile" in result[0][1]) diff --git a/xnt/tests/taskcopytests.py b/xnt/tests/taskcopytests.py index abe0eea..6b81879 100644 --- a/xnt/tests/taskcopytests.py +++ b/xnt/tests/taskcopytests.py @@ -17,30 +17,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __copy__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 class TaskCopyTests(unittest.TestCase): """Test Case for Copy Tasks Method""" - def setUp(self): - """Test Setup""" - pass - - def tearDown(self): - """Test Teardown""" - pass def test_cp(self): """Test default use of cp""" result = __copy__(srcdir="test0", dstdir="test1") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('srcdir' in result[0][1]) self.assertEqual('test0', result[0][1]['srcdir']) self.assertTrue('dstdir' in result[0][1]) @@ -49,7 +37,7 @@ class TaskCopyTests(unittest.TestCase): def test_cp_filelist(self): """Test filelist copy""" result = __copy__(files=['file1', 'file2', 'file3'], dstdir='test1') - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('files' in result[0][1]) self.assertEqual(3, len(result[0][1]['files'])) self.assertTrue('dstdir' in result[0][1]) diff --git a/xnt/tests/taskmisctests.py b/xnt/tests/taskmisctests.py index 4864e41..26ade78 100644 --- a/xnt/tests/taskmisctests.py +++ b/xnt/tests/taskmisctests.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __echo__ from xnt.tasks import __call__ from xnt.tasks import __setup__ @@ -24,29 +25,16 @@ from xnt.tasks import __xntcall__ from xnt.tasks import __which__ from xnt.tasks import __in_path__ from xnt.tasks import __log__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 class TaskMiscTests(unittest.TestCase): """Test Misc Tasks""" - def setUp(self): - """Test Case Setup""" - pass - - def tearDown(self): - """Test Case Teardown""" - pass def test_echo(self): """Test Echo Task""" result = __echo__(msg="foobar", tofile="mytestfile") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('msg' in result[0][1]) self.assertEqual('foobar', result[0][1]['msg']) self.assertTrue('tofile' in result[0][1]) @@ -55,12 +43,7 @@ class TaskMiscTests(unittest.TestCase): def test_log(self): """Test log function""" result = __log__(msg="testing the logging", lvl=40) - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('msg' in result[0][1]) self.assertEqual('testing the logging', result[0][1]['msg']) self.assertTrue('lvl' in result[0][1]) @@ -69,12 +52,7 @@ class TaskMiscTests(unittest.TestCase): def test_call(self): """Test Call, testing redirection""" result = __call__(['echo', 'blah']) - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('command' in result[0][1]) self.assertEqual(2, len(result[0][1]['command'])) self.assertEqual('echo', result[0][1]['command'][0]) @@ -87,38 +65,28 @@ class TaskMiscTests(unittest.TestCase): def test_setup_with_single_command(self): '''Test setup function with a single command''' result = __setup__(command='test') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('commands' in result[0][1]) self.assertEqual(1, len(result[0][1]['commands'])) def test_setup_with_commands(self): '''Test setup function commands''' result = __setup__(commands=['build', 'test']) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('commands' in result[0][1]) self.assertEqual(2, len(result[0][1]['commands'])) def test_setup_with_directory(self): '''Test setup function with directory''' result = __setup__(command='test', directory='test/') - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue('directory' in result[0][1]) self.assertEqual('test/', result[0][1]['directory']) def test_xntcall(self): """Test xntcall""" result = __xntcall__(buildfile='test/build.py') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('buildfile' in result[0][1]) self.assertEqual('test/build.py', result[0][1]['buildfile']) self.assertTrue('targets' in result[0][1]) @@ -127,24 +95,14 @@ class TaskMiscTests(unittest.TestCase): def test_which(self): """Test which""" result = __which__('python') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('program' in result[0][1]) self.assertEqual('python', result[0][1]['program']) def test_in_path(self): """Test in_path task""" result = __in_path__('python') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('program' in result[0][1]) self.assertEqual('python', result[0][1]['program']) diff --git a/xnt/tests/taskmkdirtests.py b/xnt/tests/taskmkdirtests.py index 3674611..0f6cc5e 100644 --- a/xnt/tests/taskmkdirtests.py +++ b/xnt/tests/taskmkdirtests.py @@ -17,8 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __mkdir__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 @@ -27,12 +27,7 @@ class TaskMkdirTests(unittest.TestCase): def test_mkdir(self): """Test mkdir method""" result = __mkdir__("my/new/directory") - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('directory' in result[0][1]) self.assertEqual('my/new/directory', result[0][1]['directory']) self.assertTrue('mode' in result[0][1]) diff --git a/xnt/tests/taskmovetests.py b/xnt/tests/taskmovetests.py index 7daaf9e..6f268bc 100644 --- a/xnt/tests/taskmovetests.py +++ b/xnt/tests/taskmovetests.py @@ -17,8 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __move__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 @@ -27,12 +27,7 @@ class TaskMoveTests(unittest.TestCase): def test_move(self): """Test Moving files and folders""" result = __move__('test0', 'test1') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('src' in result[0][1]) self.assertTrue('dst' in result[0][1]) self.assertEqual('test0', result[0][1]['src']) diff --git a/xnt/tests/taskremovetests.py b/xnt/tests/taskremovetests.py index 6768852..972520a 100644 --- a/xnt/tests/taskremovetests.py +++ b/xnt/tests/taskremovetests.py @@ -17,8 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.tasks import __remove__ -from types import FunctionType import unittest #pylint: disable-msg=C0103 @@ -27,12 +27,7 @@ class TaskRemoveTests(unittest.TestCase): def test_remove(self): """Test removing files and folders""" result = __remove__('test0', 'test1', '*swp') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('fileset' in result[0][1]) self.assertEqual(3, len(result[0][1]['fileset'])) diff --git a/xnt/tests/textests.py b/xnt/tests/textests.py index 6c14c96..86d01cf 100644 --- a/xnt/tests/textests.py +++ b/xnt/tests/textests.py @@ -17,9 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.build.tex import __pdflatex__ from xnt.build.tex import __clean__ -from types import FunctionType import unittest class TexTests(unittest.TestCase): @@ -28,12 +28,7 @@ class TexTests(unittest.TestCase): def test_pdflatex_build(self): """Test default pdflatex build""" result = __pdflatex__('test.tex', directory='tex') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('texdocument' in result[0][1]) self.assertEqual('test.tex', result[0][1]['texdocument']) self.assertTrue('directory' in result[0][1]) @@ -45,24 +40,19 @@ class TexTests(unittest.TestCase): def test_pdflatex_with_bibtex(self): """Test pdflatex with bibtex""" result = __pdflatex__('test.tex', bibtex=True) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue(result[0][1]['bibtex']) def test_pdflatex_with_glossary(self): """Test pdflatex with glossary output""" result = __pdflatex__("test.tex", makeglossary=True) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue(result[0][1]['makeglossary']) def test_tex_clean(self): """Test the default clean method removes generated files except pdf""" result = __clean__(directory='tex') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('directory' in result[0][1]) self.assertEqual('tex', result[0][1]['directory']) self.assertTrue('remove_pdf' in result[0][1]) @@ -71,7 +61,7 @@ class TexTests(unittest.TestCase): def test_tex_clean_include_pdf(self): """Test Clean; including PDF""" result = __clean__(directory='tex', remove_pdf=True) - self.assertIsNotNone(result) + assert_basic_assumptions(self, result) self.assertTrue(result[0][1]['remove_pdf']) if __name__ == '__main__': diff --git a/xnt/tests/vcscvstests.py b/xnt/tests/vcscvstests.py index ad16d15..5f52c9f 100644 --- a/xnt/tests/vcscvstests.py +++ b/xnt/tests/vcscvstests.py @@ -17,9 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.vcs.cvs import __cvsco__ from xnt.vcs.cvs import __cvsupdate__ -from types import FunctionType import unittest class VcsCvsTests(unittest.TestCase): @@ -28,12 +28,7 @@ class VcsCvsTests(unittest.TestCase): def test_cvsco(self): '''Test CVS checkout''' result = __cvsco__('mytestmodule') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('module' in result[0][1]) self.assertEqual('mytestmodule', result[0][1]['module']) self.assertTrue('rev' in result[0][1]) @@ -44,12 +39,7 @@ class VcsCvsTests(unittest.TestCase): def test_cvsupdate(self): '''Test CVS Update''' result = __cvsupdate__('./') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('./', result[0][1]['path']) diff --git a/xnt/tests/vcsgittests.py b/xnt/tests/vcsgittests.py index 5fce129..8a0785f 100644 --- a/xnt/tests/vcsgittests.py +++ b/xnt/tests/vcsgittests.py @@ -17,9 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.vcs.git import __gitclone__ from xnt.vcs.git import __gitpull__ -from types import FunctionType import unittest class VcsGitTests(unittest.TestCase): @@ -29,12 +29,7 @@ class VcsGitTests(unittest.TestCase): '''Test GIT Clone''' url = 'git://github.com/devnulltao/Xnt.git' result = __gitclone__(url) - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('url' in result[0][1]) self.assertTrue('dest' in result[0][1]) self.assertTrue('branch' in result[0][1]) @@ -45,12 +40,7 @@ class VcsGitTests(unittest.TestCase): def test_gitpull(self): '''Test GIT Pull''' result = __gitpull__('./', remote='upstream', branch='develop') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('./', result[0][1]['path']) self.assertTrue('remote' in result[0][1]) diff --git a/xnt/tests/vcshgtests.py b/xnt/tests/vcshgtests.py index 8008752..b875eac 100644 --- a/xnt/tests/vcshgtests.py +++ b/xnt/tests/vcshgtests.py @@ -17,9 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from xnt.tests import assert_basic_assumptions from xnt.vcs.hg import __hgclone__ from xnt.vcs.hg import __hgfetch__ -from types import FunctionType import unittest class VcsHgTests(unittest.TestCase): @@ -29,12 +29,7 @@ class VcsHgTests(unittest.TestCase): '''Test hg clone''' url = 'https://vim.googlecode.com/hg' result = __hgclone__(url, dest='vim') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('url' in result[0][1]) self.assertEqual(url, result[0][1]['url']) self.assertTrue('dest' in result[0][1]) @@ -47,12 +42,7 @@ class VcsHgTests(unittest.TestCase): def test_hgfetch(self): '''Test hg fetch''' result = __hgfetch__('./', source='upstream') - self.assertIsNotNone(result) - self.assertIsInstance(result, tuple) - self.assertIsInstance(result[0], tuple) - self.assertEqual(2, len(result[0])) - self.assertIsInstance(result[0][0], FunctionType) - self.assertIsInstance(result[0][1], dict) + assert_basic_assumptions(self, result) self.assertTrue('path' in result[0][1]) self.assertEqual('./', result[0][1]['path']) self.assertTrue('source' in result[0][1]) |