diff --git a/README b/README index 12f18ee6..4f2366f2 100644 --- a/README +++ b/README @@ -258,6 +258,5 @@ chmod 0600 ~/.w3m/passwd NOTES about the testsuite A new test suite has been created and should run via doing -# cd tests -# python suite.py +# ./setup.py test diff --git a/setup.py b/setup.py index e8f68063..fdc47f82 100755 --- a/setup.py +++ b/setup.py @@ -135,4 +135,5 @@ setuptools.setup( 'build_docs': build_docs, 'install_data': install_data }, + test_suite="tests", ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/suite.py b/tests/suite.py deleted file mode 100644 index 9392c6f5..00000000 --- a/tests/suite.py +++ /dev/null @@ -1,50 +0,0 @@ -import os.path -import sys -import unittest - -try: - import xmlrunner # JUnit like XML reporting - have_xmlrunner = True -except ImportError: - have_xmlrunner = False - -import test_update -import test_addfiles -import test_deletefiles -import test_revertfiles -import test_difffiles -import test_init_package -import test_init_project -import test_commit -import test_repairwc -import test_package_status -import test_project_status -import test_request -import test_setlinkrev -import test_prdiff -import test_results -import test_helpers - -suite = unittest.TestSuite() -suite.addTests(test_addfiles.suite()) -suite.addTests(test_deletefiles.suite()) -suite.addTests(test_revertfiles.suite()) -suite.addTests(test_update.suite()) -suite.addTests(test_difffiles.suite()) -suite.addTests(test_init_package.suite()) -suite.addTests(test_init_project.suite()) -suite.addTests(test_commit.suite()) -suite.addTests(test_repairwc.suite()) -suite.addTests(test_package_status.suite()) -suite.addTests(test_project_status.suite()) -suite.addTests(test_request.suite()) -suite.addTests(test_setlinkrev.suite()) -suite.addTests(test_prdiff.suite()) -suite.addTests(test_results.suite()) -suite.addTests(test_helpers.suite()) - -if have_xmlrunner: - result = xmlrunner.XMLTestRunner(output=os.path.join(os.getcwd(), 'junit-xml-results')).run(suite) -else: - result = unittest.TextTestRunner(verbosity=1).run(suite) -sys.exit(not result.wasSuccessful()) diff --git a/tests/test_addfiles.py b/tests/test_addfiles.py index 129bc4d1..75d38420 100644 --- a/tests/test_addfiles.py +++ b/tests/test_addfiles.py @@ -2,9 +2,9 @@ import osc.core import osc.oscerr import os import sys -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'addfile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures') def suite(): import unittest diff --git a/tests/test_commit.py b/tests/test_commit.py index 6c350a10..d2ba8c2e 100644 --- a/tests/test_commit.py +++ b/tests/test_commit.py @@ -2,7 +2,7 @@ import osc.core import osc.oscerr import os import sys -from common import GET, PUT, POST, DELETE, OscTestCase +from .common import GET, PUT, POST, DELETE, OscTestCase try: # Works up to Python 3.8, needed for Python < 3.3 (inc 2.7) from xml.etree import cElementTree as ET @@ -16,7 +16,7 @@ except ImportError: #python 2.x from urllib2 import HTTPError -FIXTURES_DIR = os.path.join(os.getcwd(), 'commit_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures') def suite(): import unittest diff --git a/tests/test_deletefiles.py b/tests/test_deletefiles.py index 8b38c364..566ddf47 100644 --- a/tests/test_deletefiles.py +++ b/tests/test_deletefiles.py @@ -1,9 +1,9 @@ import osc.core import osc.oscerr import os -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'deletefile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures') def suite(): import unittest diff --git a/tests/test_difffiles.py b/tests/test_difffiles.py index 3c430d8b..43cd570d 100644 --- a/tests/test_difffiles.py +++ b/tests/test_difffiles.py @@ -3,9 +3,9 @@ import osc.oscerr from osc.util.helper import decode_list import os import re -from common import GET, OscTestCase +from .common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'difffile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures') def suite(): import unittest diff --git a/tests/test_init_package.py b/tests/test_init_package.py index 7347506f..c513bdd6 100644 --- a/tests/test_init_package.py +++ b/tests/test_init_package.py @@ -1,8 +1,8 @@ import osc.core import osc.oscerr import os -from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'init_package_fixtures') +from .common import OscTestCase +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures') def suite(): import unittest diff --git a/tests/test_init_project.py b/tests/test_init_project.py index f4714dc2..ff9dfb9e 100644 --- a/tests/test_init_project.py +++ b/tests/test_init_project.py @@ -1,8 +1,8 @@ import osc.core import osc.oscerr import os -from common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'init_project_fixtures') +from .common import GET, OscTestCase +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures') def suite(): import unittest diff --git a/tests/test_package_status.py b/tests/test_package_status.py index 430adec0..0fefb4e3 100644 --- a/tests/test_package_status.py +++ b/tests/test_package_status.py @@ -1,9 +1,9 @@ import osc.core import osc.oscerr import os -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures') def suite(): import unittest diff --git a/tests/test_prdiff.py b/tests/test_prdiff.py index 9838ba86..8ab47e76 100644 --- a/tests/test_prdiff.py +++ b/tests/test_prdiff.py @@ -4,10 +4,10 @@ import osc.oscerr import os import re import sys -from common import GET, POST, OscTestCase, addExpectedRequest, EXPECTED_REQUESTS +from .common import GET, POST, OscTestCase, addExpectedRequest, EXPECTED_REQUESTS -FIXTURES_DIR = os.path.join(os.getcwd(), 'prdiff_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'prdiff_fixtures') API_URL = 'http://localhost/' UPSTREAM = 'some:project' BRANCH = 'home:user:branches:' + UPSTREAM diff --git a/tests/test_project_status.py b/tests/test_project_status.py index 3c8497f5..696f97b5 100644 --- a/tests/test_project_status.py +++ b/tests/test_project_status.py @@ -1,9 +1,9 @@ import osc.core import osc.oscerr import os -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures') def suite(): import unittest diff --git a/tests/test_repairwc.py b/tests/test_repairwc.py index 01ed6aaa..0a4d506a 100644 --- a/tests/test_repairwc.py +++ b/tests/test_repairwc.py @@ -2,7 +2,7 @@ import osc.core import osc.oscerr import os import sys -from common import GET, PUT, POST, DELETE, OscTestCase +from .common import GET, PUT, POST, DELETE, OscTestCase try: # Works up to Python 3.8, needed for Python < 3.3 (inc 2.7) from xml.etree import cElementTree as ET @@ -10,7 +10,7 @@ except ImportError: # will import a fast implementation from 3.3 onwards, needed # for 3.9+ from xml.etree import ElementTree as ET -FIXTURES_DIR = os.path.join(os.getcwd(), 'repairwc_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures') def suite(): import unittest diff --git a/tests/test_request.py b/tests/test_request.py index 32e507f0..7840a13f 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -9,9 +9,9 @@ except ImportError: import osc.core import osc.oscerr import os -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'request_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures') def suite(): import unittest diff --git a/tests/test_results.py b/tests/test_results.py index 856560cd..1d4d9660 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -1,5 +1,5 @@ import osc.commandline -from common import GET, OscTestCase +from .common import GET, OscTestCase import os import sys diff --git a/tests/test_revertfiles.py b/tests/test_revertfiles.py index 5a8c4433..121fea39 100644 --- a/tests/test_revertfiles.py +++ b/tests/test_revertfiles.py @@ -1,9 +1,9 @@ import osc.core import osc.oscerr import os -from common import OscTestCase +from .common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'revertfile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures') def suite(): import unittest diff --git a/tests/test_setlinkrev.py b/tests/test_setlinkrev.py index 2e91f54e..b4da4743 100644 --- a/tests/test_setlinkrev.py +++ b/tests/test_setlinkrev.py @@ -1,8 +1,8 @@ import osc.core import osc.oscerr import os -from common import GET, PUT, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'setlinkrev_fixtures') +from .common import GET, PUT, OscTestCase +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures') def suite(): import unittest diff --git a/tests/test_update.py b/tests/test_update.py index ef3b7963..251268e8 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -2,8 +2,8 @@ import osc.core import osc.oscerr import os import sys -from common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'update_fixtures') +from .common import GET, OscTestCase +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures') def suite(): import unittest