Skip to content
Snippets Groups Projects
Commit 9aaf1457 authored by Mayr, Hannes's avatar Mayr, Hannes
Browse files

Skip unit tests that don't work if tests are run from command line.

parent 639cf05b
Branches
No related tags found
2 merge requests!59Version v0.2.3,!53Resolve "Unit tests fail if called from command line"
Pipeline #856239 waiting for manual action
......@@ -74,9 +74,8 @@ class PublishOptions:
if not os.path.isfile(sys.argv[0]):
raise FileNotFoundError(
"Cannot copy original python script. "
"Running publish from a shell is not "
"possible."
"Cannot copy original python script. Running publish from a shell is "
"not possible."
)
# Check if self.src_datapaths are strings and existing files.
......
......
......@@ -45,8 +45,7 @@ class TestPublish(unittest.TestCase):
# Skip test if tests are run from command line.
@unittest.skipIf(
not os.path.isfile(sys.argv[0]),
"Publish is not called "
"from a Python script. Therefore, the script cannot be "
"Publish is not called from a Python script. Therefore, the script cannot be "
"copied.",
)
def test_publish(self):
......@@ -112,6 +111,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(TypeError):
publish(PlotIDTransfer(FIG, ["i", 4]), SRC_DIR, DST_PATH)
# Skip test if tests are run from command line.
@unittest.skipIf(
not os.path.isfile(sys.argv[0]),
"Publish is not called from a Python script. Therefore, the script cannot be "
"copied.",
)
def test_publish_multiple_src_files(self):
"""
Test publish with multiple source files and check
......@@ -137,6 +142,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(FileNotFoundError):
publish(FIGS_AND_IDS, "not_existing_folder", DST_PATH)
# Skip test if tests are run from command line.
@unittest.skipIf(
not os.path.isfile(sys.argv[0]),
"Publish is not called from a Python script. Therefore, the script cannot be "
"copied.",
)
def test_src_directory_type(self):
"""Test if Error is raised when source directory is not a string."""
with self.assertRaises(TypeError):
......@@ -260,8 +271,7 @@ class TestPublish(unittest.TestCase):
# Skip test if tests are run from command line.
@unittest.skipIf(
not os.path.isfile(sys.argv[0]),
"Publish is not called "
"from a Python script. Therefore, the script cannot be "
"Publish is not called from a Python script. Therefore, the script cannot be "
"copied.",
)
def test_dst_invisible_already_exists(self):
......@@ -290,6 +300,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(TypeError):
publish(FIGS_AND_IDS, SRC_DIR, DST_PATH, ["test", 3])
# Skip test if tests are run from command line.
@unittest.skipIf(
not os.path.isfile(sys.argv[0]),
"Publish is not called from a Python script. Therefore, the script cannot be "
"copied.",
)
def test_data_storage(self):
"""
Test if Error is raised when unsupported storage method was chosen.
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment