Fixed bugs with unit test on Python 3

This commit is contained in:
Nic Herndon
2018-06-30 23:06:42 +00:00
parent d95c32f4b8
commit 03a4172680
7 changed files with 12 additions and 11 deletions
+1 -1
View File
@@ -683,7 +683,7 @@ class BcfUncompressed(Bcf):
def sniff(self, filename):
try:
header = open(filename).read(3)
header = open(filename, mode='rb').read(3)
# The first 3 bytes of any BCF file are 'BCF', and the file is binary.
if header == b'BCF':
return True
+2 -1
View File
@@ -252,7 +252,8 @@ class XmlToolSource(ToolSource):
data_dict[output_def.name] = output_def
return output_def
map(_parse, out_elem.findall("data"))
for _ in out_elem.findall("data"):
_parse(_)
for collection_elem in out_elem.findall("collection"):
name = collection_elem.get("name")
+1 -1
View File
@@ -79,7 +79,7 @@ def check_gzip(file_path, check_content=True):
# If the file is Bam, it should already have been detected as such, so we'll just check
# for sff format.
try:
header = gzip.open(file_path).read(4)
header = gzip.open(file_path, 'rb').read(4)
if header == b'.sff':
return (True, True)
except Exception:
+3 -3
View File
@@ -21,7 +21,7 @@ def test_missing_parameter():
runners.RunnerParams(specs={}, params=dict(foo="bar"))
except Exception as e:
exception = e
assert exception.message == runners.JOB_RUNNER_PARAMETER_UNKNOWN_MESSAGE % "foo"
assert str(exception) == runners.JOB_RUNNER_PARAMETER_UNKNOWN_MESSAGE % "foo"
def test_invalid_parameter():
@@ -30,7 +30,7 @@ def test_invalid_parameter():
runners.RunnerParams(specs=dict(foo=dict(valid=lambda x: x != "bar", defualt="baz")), params=dict(foo="bar"))
except Exception as e:
exception = e
assert exception.message == runners.JOB_RUNNER_PARAMETER_VALIDATION_FAILED_MESSAGE % "foo"
assert str(exception) == runners.JOB_RUNNER_PARAMETER_VALIDATION_FAILED_MESSAGE % "foo"
def test_map_problem():
@@ -39,7 +39,7 @@ def test_map_problem():
runners.RunnerParams(specs=dict(foo=dict(map=lambda x: 1 / 0, default="baz")), params=dict(foo="bar"))
except Exception as e:
exception = e
assert exception.message == runners.JOB_RUNNER_PARAMETER_MAP_PROBLEM_MESSAGE % ("foo", "bar")
assert str(exception) == runners.JOB_RUNNER_PARAMETER_MAP_PROBLEM_MESSAGE % ("foo", "bar")
def test_param_default():
+3 -3
View File
@@ -177,11 +177,11 @@ class XmlLoaderTestCase(BaseLoaderTestCase):
def test_requirements(self):
requirements, containers = self._tool_source.parse_requirements_and_containers()
assert requirements[0].type == "package"
assert containers[0].identifier == "mycool/bwa"
assert list(containers)[0].identifier == "mycool/bwa"
def test_outputs(self):
outputs, output_collections = self._tool_source.parse_outputs(object())
assert len(outputs) == 1
assert len(outputs) == 1, outputs
assert len(output_collections) == 0
def test_stdio(self):
@@ -339,7 +339,7 @@ class YamlLoaderTestCase(BaseLoaderTestCase):
page_sources = input_pages.page_sources
assert len(page_sources) == 1
page_source = page_sources[0]
input_sources = page_source.parse_input_sources()
input_sources = list(page_source.parse_input_sources())
assert len(input_sources) == 2
def test_tests(self):
@@ -35,7 +35,7 @@ def test_serialization():
assert result_requirement.version == "2.0"
assert result_requirement.type == "package"
result_tool_shed_dependency = result_descript.installed_tool_dependencies[0]
result_tool_shed_dependency = list(result_descript.installed_tool_dependencies)[0]
result_tool_shed_dependency.name = "tophat"
result_tool_shed_dependency.version = "2.0"
result_tool_shed_dependency.type = "package"
+1 -1
View File
@@ -55,7 +55,7 @@ class TestWorkflowExtractSummary(unittest.TestCase):
assert len(job_dict) == 1
fake_job = job_dict.keys()[0]
assert fake_job.id.startswith("fake_")
datasets = job_dict.values()[0]
datasets = list(job_dict.values())[0]
assert datasets == [(None, hda)]
def test_fake_job_hdca(self):