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
No related branches found
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: ...@@ -74,9 +74,8 @@ class PublishOptions:
if not os.path.isfile(sys.argv[0]): if not os.path.isfile(sys.argv[0]):
raise FileNotFoundError( raise FileNotFoundError(
"Cannot copy original python script. " "Cannot copy original python script. Running publish from a shell is "
"Running publish from a shell is not " "not possible."
"possible."
) )
# Check if self.src_datapaths are strings and existing files. # Check if self.src_datapaths are strings and existing files.
......
...@@ -45,8 +45,7 @@ class TestPublish(unittest.TestCase): ...@@ -45,8 +45,7 @@ class TestPublish(unittest.TestCase):
# Skip test if tests are run from command line. # Skip test if tests are run from command line.
@unittest.skipIf( @unittest.skipIf(
not os.path.isfile(sys.argv[0]), not os.path.isfile(sys.argv[0]),
"Publish is not called " "Publish is not called from a Python script. Therefore, the script cannot be "
"from a Python script. Therefore, the script cannot be "
"copied.", "copied.",
) )
def test_publish(self): def test_publish(self):
...@@ -112,6 +111,12 @@ class TestPublish(unittest.TestCase): ...@@ -112,6 +111,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
publish(PlotIDTransfer(FIG, ["i", 4]), SRC_DIR, DST_PATH) 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): def test_publish_multiple_src_files(self):
""" """
Test publish with multiple source files and check Test publish with multiple source files and check
...@@ -137,6 +142,12 @@ class TestPublish(unittest.TestCase): ...@@ -137,6 +142,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(FileNotFoundError): with self.assertRaises(FileNotFoundError):
publish(FIGS_AND_IDS, "not_existing_folder", DST_PATH) 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): def test_src_directory_type(self):
"""Test if Error is raised when source directory is not a string.""" """Test if Error is raised when source directory is not a string."""
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
...@@ -260,8 +271,7 @@ class TestPublish(unittest.TestCase): ...@@ -260,8 +271,7 @@ class TestPublish(unittest.TestCase):
# Skip test if tests are run from command line. # Skip test if tests are run from command line.
@unittest.skipIf( @unittest.skipIf(
not os.path.isfile(sys.argv[0]), not os.path.isfile(sys.argv[0]),
"Publish is not called " "Publish is not called from a Python script. Therefore, the script cannot be "
"from a Python script. Therefore, the script cannot be "
"copied.", "copied.",
) )
def test_dst_invisible_already_exists(self): def test_dst_invisible_already_exists(self):
...@@ -290,6 +300,12 @@ class TestPublish(unittest.TestCase): ...@@ -290,6 +300,12 @@ class TestPublish(unittest.TestCase):
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
publish(FIGS_AND_IDS, SRC_DIR, DST_PATH, ["test", 3]) 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): def test_data_storage(self):
""" """
Test if Error is raised when unsupported storage method was chosen. 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 register or to comment