Skip to content

Commit 83809b3

Browse files
committed
another round of changes for testing
1 parent dedde3e commit 83809b3

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

singularity/tests/test_analysis_classify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_estimate_os(self):
6464
print("Testing singularity.analysis.classify.estimate_os")
6565
from singularity.analysis.classify import estimate_os
6666
estimated_os = estimate_os(self.container)
67-
self.assertTrue(estimated_os.startswith('ubuntu')
67+
self.assertTrue(estimated_os.startswith('ubuntu'))
6868

6969

7070
def test_get_tags(self):

singularity/tests/test_analysis_compare.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
assert_equal
3535
)
3636

37+
from singularity.utils import get_installdir
3738
from singularity.cli import get_image
3839
import unittest
3940
import tempfile
@@ -56,7 +57,7 @@ def test_container_similarity_vector(self):
5657
print("Testing singularity.analysis.compare.container_similarity_vector")
5758
import pandas
5859
from singularity.analysis.compare import container_similarity_vector
59-
from.singularity.analysis.utils import get_packages
60+
from singularity.analysis.utils import get_packages
6061
packages_set = get_packages('docker-os')[0:2]
6162
vector = container_similarity_vector(container1=self.container,
6263
custom_set=packages_set)
@@ -70,7 +71,7 @@ def test_compare_singularity_images(self):
7071
from singularity.analysis.compare import compare_singularity_images
7172
sim = compare_singularity_images(self.container,self.comparator)
7273
self.assertTrue(isinstance(sim,pandas.DataFrame))
73-
self.assertTrue(sim.loc[container,comparator] - 0.4803262269280298 < 0.01)
74+
self.assertTrue(sim.loc[self.container,self.comparator] - 0.4803262269280298 < 0.01)
7475

7576

7677
def test_compare_containers(self):
@@ -80,7 +81,7 @@ def test_compare_containers(self):
8081
self.assertTrue('files.txt' in comparison)
8182
for key in ['total1', 'total2', 'intersect', 'unique2', 'unique1']:
8283
self.assertTrue(key in comparison['files.txt'])
83-
self.assertEqual(len(comparison['files.txt']['intersect']),2567)
84+
self.assertEqual(len(comparison['files.txt']['intersect']),2565)
8485

8586

8687
def test_calculate_similarity(self):

singularity/tests/test_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,19 @@ def test_pull(self):
9696

9797
print("Case 1: Testing naming pull by image name")
9898
image = self.cli.pull("shub://vsoch/singularity-images")
99+
print(image)
99100
self.assertTrue(os.path.exists(image))
100101
self.assertTrue("vsoch-singularity-images" in image)
101102

102103
print("Case 2: Testing naming pull by image commit")
103104
image = self.cli.pull("shub://vsoch/singularity-images",name_by="commit")
105+
print(image)
104106
self.assertTrue(os.path.exists(image))
105107
self.assertTrue("7a75cd7a32192e5d50f267982e0c30aff794076b" in image)
106108

107109
print("Case 3: Testing naming pull by image hash")
108110
image = self.cli.pull("shub://vsoch/singularity-images",name_by="hash")
111+
print(image)
109112
self.assertTrue(os.path.exists(image))
110113
self.assertTrue("a989bc72cb154d007aa47a5034978328" in image)
111114

@@ -123,11 +126,12 @@ def test_get_image(self):
123126
def create_container(container=None,do_import=False):
124127
'''supporting function to create empty container
125128
'''
129+
cli = Singularity()
126130
if container is None:
127131
container = "%s/container.img" %(self.tmpdir)
128132
if do_import is True:
129-
self.cli.importcmd(container,'docker://ubuntu')
130-
return self.cli.create(container)
133+
cli.importcmd(container,'docker://ubuntu')
134+
return cli.create(container)
131135

132136

133137
if __name__ == '__main__':

singularity/tests/test_reproduce.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_get_memory_tar(self):
7171
file_obj.close()
7272

7373
def test_get_image_hashes(self):
74-
from singularity.reproduce import get_image_hashes
74+
from singularity.reproduce import get_image_hashes, get_image_hash
7575

7676
print("Case 1: No specification of version returns latest")
7777
hashes = get_image_hashes(self.image1)
@@ -116,7 +116,7 @@ def test_get_level(self):
116116
for key in ['assess_content','skip_files','regexp','description']:
117117
self.assertTrue(key in level)
118118

119-
def test_get_levels(version=None):
119+
def test_get_levels(self):
120120
from singularity.reproduce import get_levels
121121
print("Testing singularity.reproduce.get_levels")
122122

@@ -138,7 +138,7 @@ def test_get_content_hashes(self):
138138
hashes = get_content_hashes(self.image1)
139139
for key in ['hashes','sizes','root_owned']:
140140
self.assertTrue(key in hashes)
141-
self.assertEqual(len(hashes),372)
141+
self.assertEqual(len(hashes['hashes']),372)
142142

143143

144144
def test_extract_guts(self):

singularity/tests/test_utils.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,35 +107,25 @@ def test_get_installdir(self):
107107
self.assertTrue(whereami.endswith('singularity'))
108108

109109

110-
def test_zip_up(self):
111-
'''zip up should create a zip file from a specified directory
112-
'''
113-
from singularity.utils import zip_up
114-
zip_dir = tempfile.mkdtemp()
115-
zip_name = "beetlejuice.zip"
116-
zip_file = zip_dir(zip_dir, zip_name, output_folder=self.tmpdir)
117-
self.assertTrue(os.path.exists(zip_file))
118-
119-
120110
def test_calculate_folder_size(self):
121111
'''ensure that calculation of folder size is accurate
122112
'''
123113
from singularity.utils import calculate_folder_size
124114
size_truncated = calculate_folder_size(self.tmpdir)
125-
self.assertTrue(isinstance(size,int))
115+
self.assertTrue(isinstance(size_truncated,int))
126116
size = calculate_folder_size(self.tmpdir,truncate=False)
127117
self.assertTrue(isinstance(size,float))
128118

129119

130120
def test_remove_uri(self):
131121
from singularity.utils import remove_uri
132-
self.assertEqual('docker://ubuntu','ubuntu')
133-
self.assertEqual('shub://vanessa/singularity-images','vanessa/singularity-images')
122+
self.assertEqual(remove_uri('docker://ubuntu'),'ubuntu')
123+
self.assertEqual(remove_uri('shub://vanessa/singularity-images'),'vanessa/singularity-images')
134124

135125

136126
def test_download_repo(self):
137127
from singularity.utils import download_repo
138-
download_repo('https://github.com/singularityware/singularity',destination=self.tmpdir)
128+
download_repo('https://github.com/singularityware/singularity',destination="%s/singularity" %self.tmpdir)
139129
self.assertTrue(os.path.exists("%s/singularity" %self.tmpdir))
140130

141131

0 commit comments

Comments
 (0)