(utils/tap/model) Prefer pytest-style tests -- Refs
@@ -14,7 +14,6 @@ Created on 30 jun. 2016
"""
-import unittest
import os
import pytest
@@ -29,15 +28,14 @@ def data_path(filename):
return os.path.join(data_dir, filename)
-class TestJob(unittest.TestCase):
-
- def test_job_basic(self):
+def test_job_basic():
with pytest.raises(AttributeError):
job = Job(async_job=True)
job.get_results()
- def test_job_get_results(self):
+
+def test_job_get_results():
job = Job(async_job=True)
jobid = "12345"
outputFormat = "votable"
@@ -78,15 +76,14 @@ class TestJob(unittest.TestCase):
responseGetData.set_status_code(200)
responseGetData.set_message("OK")
res = job.get_results()
- assert len(res) == 3, \
- "Num rows. Expected %d, found %d" % (3, len(res))
- assert len(res.columns) == 4, \
- "Num cols. Expected %d, found %d" % (4, len(res.columns))
+ assert len(res) == 3
+ assert len(res.columns) == 4
for cn in ['alpha', 'delta', 'source_id', 'table1_oid']:
if cn not in res.colnames:
- self.fail(cn + " column name not found" + str(res.colnames))
+ pytest.fail(cn + " column name not found" + str(res.colnames))
+
- def test_job_phase(self):
+def test_job_phase():
job = Job(async_job=True)
jobid = "12345"
outputFormat = "votable"
@@ -95,27 +92,22 @@ class TestJob(unittest.TestCase):
job.set_phase("COMPLETED")
try:
job.set_phase("RUN")
- self.fail("Exception expected. " +
+ pytest.fail("Exception expected. " +
"Phase cannot be changed for a finished job")
except ValueError:
# ok
pass
try:
job.start()
- self.fail("Exception expected. " +
+ pytest.fail("Exception expected. " +
"A job in 'COMPLETE' phase cannot be started")
except ValueError:
# ok
pass
try:
job.abort()
- self.fail("Exception expected. " +
+ pytest.fail("Exception expected. " +
"A job in 'COMPLETE' phase cannot be aborted")
except ValueError:
# ok
pass
-
-
-if __name__ == "__main__":
- # import sys;sys.argv = ['', 'Test.testName']
- unittest.main()
