diff --git a/src/omero/util/import_candidates.py b/src/omero/util/import_candidates.py index 2ac36dd80..8824b602b 100644 --- a/src/omero/util/import_candidates.py +++ b/src/omero/util/import_candidates.py @@ -47,7 +47,7 @@ def as_stdout(path, readers="", extra_args=None): cli = CLI() cli.loadplugins() if readers: - cli.invoke(["import", "-l"] + extra_args + [readers, "-f"] + path) + cli.invoke(["import", "-l"] + [readers,] + extra_args + ["-f"] + path) else: cli.invoke(["import"] + extra_args + ["-f"] + path) if cli.rv != 0: diff --git a/test/unit/clitest/test_import.py b/test/unit/clitest/test_import.py index 7dbdcd1a1..d3e6f8977 100644 --- a/test/unit/clitest/test_import.py +++ b/test/unit/clitest/test_import.py @@ -541,3 +541,26 @@ def testImportCandidatesDepth(self, tmpdir): ) assert str(fakefile) in candidates assert str(fakefile2) not in candidates + + @pytest.mark.skipif(sys.platform == "win32", reason="Fails on Windows") + def testImportCandidatesReaders(self, tmpdir): + """ + Test using import_candidates with a populated readers.txt + """ + fakefile = tmpdir.join("test.fake") + fakefile.write('') + patternfile = tmpdir.join("test.pattern") + patternfile.write('test.fake') + readers = tmpdir.join("readers.txt") + readers.write('loci.formats.in.FakeReader') + candidates = import_candidates.as_dictionary(str(tmpdir)) + assert str(patternfile) in candidates + assert str(fakefile) in candidates[str(patternfile)] + candidates = import_candidates.as_dictionary( + str(tmpdir), readers=str(readers)) + assert str(fakefile) in candidates + assert str(patternfile) not in candidates + candidates = import_candidates.as_dictionary( + str(tmpdir), readers=str(readers), extra_args=["--debug", "WARN"]) + assert str(fakefile) in candidates + assert str(patternfile) not in candidates